use of org.eclipse.swt.layout.FormLayout in project cogtool by cogtool.
the class WebCrawlImportDialog method buildSecondGroup.
public void buildSecondGroup() {
typeHTMLGroup2 = new Group(useSelectionGroup, SWT.SHADOW_NONE);
typeHTMLGroup2.setText("Starting URL #2");
typeHTMLGroup2.setLayout(new FormLayout());
urlText2 = new TextWithEnableFix(typeHTMLGroup2, SWT.BORDER | SWT.SINGLE);
urlText2.setText("http://");
urlText2.setVisible(false);
urlText2.addTraverseListener(new TraverseListener() {
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
e.detail = SWT.TRAVERSE_NONE;
questionMarkButtonDomain.forceFocus();
}
}
});
urlPath4 = new Label(typeHTMLGroup2, SWT.NONE);
urlPath5 = new Label(typeHTMLGroup2, SWT.NONE);
urlPath6 = new Label(typeHTMLGroup2, SWT.NONE);
urlPath6b = new Label(typeHTMLGroup2, SWT.NONE);
urlPath6b.setText("path");
urlPath6b.setFont(URL_PATH_FONT);
urlPath6b.setVisible(false);
useHTML4 = new Button(typeHTMLGroup2, SWT.RADIO);
useHTML4.addSelectionListener(domainListener);
useHTML4.setSelection(true);
useHTML5 = new Button(typeHTMLGroup2, SWT.RADIO);
useHTML5.addSelectionListener(domainListener);
useHTML6 = new Button(typeHTMLGroup2, SWT.RADIO);
useHTML6.addSelectionListener(domainListener);
plusButton2 = makeToolBarButton(typeHTMLGroup2, addGroupListener, questionImages.PLUS_IMAGE);
minusButton2 = makeToolBarButton(typeHTMLGroup2, minusGroupListener2, questionImages.MINUS_IMAGE);
questionMarkButtonDepth2 = makeToolBarButton(typeHTMLGroup2, depthListener, questionImages.QUESTION_SHADOW);
maximumDepthToCrawlLabel2 = new Label(typeHTMLGroup2, SWT.NONE);
maximumDepthToCrawlLabel2.setText("Maximum Depth To Crawl: ");
maxDepthCombo2 = new ComboWithEnableFix(typeHTMLGroup2, SWT.DROP_DOWN | SWT.READ_ONLY);
maxDepthCombo2.add("Unlimited");
for (int i = 0; i < 100; i++) {
maxDepthCombo2.add("" + i);
}
maxDepthCombo2.select(2);
maxDepthCombo2.setVisibleItemCount(21);
maxDepthCombo2.addSelectionListener(comboListener);
restrictDomainLabel2 = new Label(typeHTMLGroup2, SWT.NONE);
restrictDomainLabel2.setText("Restrict Domain: ");
questionMarkButtonDomain2 = makeToolBarButton(typeHTMLGroup2, domainHelpListener, questionImages.QUESTION_SHADOW);
questionMarkButtonDomain2.setVisible(false);
questionMarkButtonDomain2.addTraverseListener(new TraverseListener() {
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_TAB_NEXT) {
if (numOfGroups > 2) {
e.detail = SWT.TRAVERSE_NONE;
urlText3.forceFocus();
}
}
}
});
urlText2.addFocusListener(new TextFocusListener(urlText2, urlPath5, urlPath6, useHTML4, useHTML5, useHTML6, 2));
}
use of org.eclipse.swt.layout.FormLayout 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();
}
use of org.eclipse.swt.layout.FormLayout in project translationstudio8 by heartsome.
the class TSTitleAreaDialog method createContents.
/*
* @see Dialog.createContents(Composite)
*/
protected Control createContents(Composite parent) {
// create the overall composite
Composite contents = new Composite(parent, SWT.NONE);
contents.setLayoutData(new GridData(GridData.FILL_BOTH));
// initialize the dialog units
initializeDialogUnits(contents);
FormLayout layout = new FormLayout();
contents.setLayout(layout);
// Now create a work area for the rest of the dialog
workArea = new Composite(contents, SWT.NONE);
GridLayout childLayout = new GridLayout();
childLayout.marginHeight = 0;
childLayout.marginWidth = 0;
childLayout.verticalSpacing = 0;
workArea.setLayout(childLayout);
Control top = createTitleArea(contents);
resetWorkAreaAttachments(top);
workArea.setFont(JFaceResources.getDialogFont());
// initialize the dialog units
initializeDialogUnits(workArea);
// create the dialog area and button bar
dialogArea = createDialogArea(workArea);
buttonBar = createButtonBar(workArea);
// computing trim for later
Point rect = messageLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
xTrim = rect.x - 100;
yTrim = rect.y - 100;
// need to react to new size of title area
getShell().addListener(SWT.Resize, new Listener() {
public void handleEvent(Event event) {
layoutForNewMessage(true);
}
});
return contents;
}
use of org.eclipse.swt.layout.FormLayout in project cubrid-manager by CUBRID.
the class QueryResultComposite method makeResult.
/**
* make the result contents.
*
* @param result QueryExecuter
*/
private void makeResult(final QueryExecuter result, CTabFolder parentFolder) {
editor.getCombinedQueryComposite().getRecentlyUsedSQLComposite().refreshRecentlyUsedSQLList();
//final CTabFolder queryResultTabFolder = ((QueryResultComposite)queryResultTabItem.getControl()).queryResultTabFolder;
ViewForm viewForm = new ViewForm(parentFolder, SWT.NONE);
// create the bottom sash
final SashForm tableLogSash = new SashForm(viewForm, SWT.VERTICAL);
tableLogSash.SASH_WIDTH = SASH_WIDTH;
tableLogSash.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
final Composite resultContainer = new Composite(tableLogSash, SWT.None);
resultContainer.setLayout(new FormLayout());
final Table resultTable = new Table(resultContainer, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION);
setDropTraget(resultTable);
resultTable.setHeaderVisible(true);
resultTable.setLinesVisible(true);
resultTable.setBackground(BACKGROUND_NORMAL);
CommonUITool.hackForYosemite(resultTable);
// display data compare label for multiple queries
if (this.multiResultsCompare == true) {
Composite compareButtonComposite = new Composite(resultContainer, SWT.None);
compareButtonComposite.setLayout(new FillLayout());
displayDataCompareLabel(compareButtonComposite, resultTable);
FormData tableData = new FormData();
tableData.top = new FormAttachment(0, 0);
tableData.bottom = new FormAttachment(100, -28);
tableData.left = new FormAttachment(0, 0);
tableData.right = new FormAttachment(100, 0);
resultTable.setLayoutData(tableData);
FormData compareData = new FormData();
compareData.top = new FormAttachment(100, -28);
compareData.bottom = new FormAttachment(100, 0);
compareData.left = new FormAttachment(0, 0);
compareData.right = new FormAttachment(100, 0);
compareButtonComposite.setLayoutData(compareData);
} else {
FormData tableData = new FormData();
tableData.top = new FormAttachment(0, 0);
tableData.bottom = new FormAttachment(100, 0);
tableData.left = new FormAttachment(0, 0);
tableData.right = new FormAttachment(100, 0);
resultTable.setLayoutData(tableData);
}
final SashForm logSash = new SashForm(tableLogSash, SWT.HORIZONTAL);
logSash.SASH_WIDTH = SASH_WIDTH;
logSash.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
logSash.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
StyledText messagesArea = new StyledText(logSash, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY | SWT.WRAP);
CommonUITool.registerCopyPasteContextMenu(messagesArea, false, false);
tableLogSash.setWeights(new int[] { 8, 2 });
messagesArea.setToolTipText(Messages.tooltipHowToExpandLogPane);
messagesArea.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent e) {
tableLogSash.setWeights(new int[] { 8, 2 });
}
public void focusGained(FocusEvent e) {
tableLogSash.setWeights(new int[] { 2, 8 });
}
});
TableCursor cursor = new TableCursor(resultTable, SWT.NONE);
TableSelectSupport tableSelectSupport = new TableSelectSupport(resultTable, cursor);
if (this.multiResultsCompare == true) {
result.setMultiResultsCompare(true);
result.setBaseQueryExecuter(this.baseQueryExecuter);
}
result.makeResult(tableSelectSupport, messagesArea, isMutliQuery);
// Auto set column size, maximum is 300px,minimum is 50px
for (int i = 1; i < resultTable.getColumnCount(); i++) {
resultTable.getColumns()[i].pack();
if (resultTable.getColumns()[i].getWidth() > 300) {
resultTable.getColumns()[i].setWidth(300);
}
if (resultTable.getColumns()[i].getWidth() < 50) {
resultTable.getColumns()[i].setWidth(50);
}
}
// fill the view form action on top right corner
ToolBar topRightToolBar = new ToolBar(viewForm, SWT.FLAT);
ToolBarManager toolBarManager = new ToolBarManager(topRightToolBar);
result.makeActions(toolBarManager, resultTable);
// fill the view form action on top right corner
ToolBar topLeftToolBar = new ToolBar(viewForm, SWT.FLAT);
swRecordItem = new ToolItem(topLeftToolBar, SWT.CHECK);
result.swRecordItem = swRecordItem;
swRecordItem.setToolTipText(Messages.getOidOn);
swRecordItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_update.png"));
swRecordItem.setEnabled(true);
swRecordItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (editor.isCollectExecStats()) {
result.swRecordItem.setSelection(false);
CommonUITool.openErrorBox(getShell(), Messages.errNotEditableOnStat);
return;
}
if (!result.isContainPrimayKey()) {
result.swRecordItem.setSelection(false);
CommonUITool.openErrorBox(getShell(), Messages.errNoPrimaryKey);
return;
}
if (!result.isSingleTableQuery()) {
result.swRecordItem.setSelection(false);
CommonUITool.openErrorBox(getShell(), Messages.errNotInOneTable);
return;
}
if (!checkConnection()) {
result.swRecordItem.setSelection(false);
CommonUITool.openErrorBox(getShell(), Messages.errMsgExecuteInResult);
return;
}
result.tblResult.forceFocus();
if (result.swRecordItem.getSelection()) {
result.swRecordItem.setToolTipText(Messages.getOidOn);
result.setEditMode(true);
result.insertRecordItem.setEnabled(true);
if (result.tblResult.getSelectionCount() > 0) {
result.delRecordItem.setEnabled(true);
}
} else {
if (result.isModifiedResult()) {
result.swRecordItem.setSelection(true);
CommonUITool.openErrorBox(getShell(), Messages.errHasNoCommit);
return;
}
result.swRecordItem.setToolTipText(Messages.getOidOff);
result.setEditMode(false);
result.insertRecordItem.setEnabled(false);
result.delRecordItem.setEnabled(false);
}
}
});
//added by kevin, for insert record
insertRecordItem = new ToolItem(topLeftToolBar, SWT.PUSH);
result.insertRecordItem = insertRecordItem;
insertRecordItem.setToolTipText(com.cubrid.common.ui.cubrid.table.Messages.insertInstanceMsgTitle);
insertRecordItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/table_record_insert.png"));
insertRecordItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/table_record_insert_disabled.png"));
insertRecordItem.setEnabled(false);
insertRecordItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (!result.getEditable()) {
CommonUITool.openErrorBox(getShell(), Messages.errNotEditable);
return;
}
if (!checkConnection()) {
CommonUITool.openErrorBox(getShell(), Messages.errMsgExecuteInResult);
return;
}
result.insertSaveItem.setEnabled(result.getEditable());
result.rollbackModifiedItem.setEnabled(result.getEditable());
result.addNewItem();
}
});
delRecordItem = new ToolItem(topLeftToolBar, SWT.PUSH);
result.delRecordItem = delRecordItem;
delRecordItem.setToolTipText(Messages.delete);
delRecordItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/table_record_delete.png"));
delRecordItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/table_record_delete_disabled.png"));
delRecordItem.setEnabled(false);
delRecordItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (!result.getEditable()) {
CommonUITool.openErrorBox(getShell(), Messages.errNotEditable);
return;
}
if (!checkConnection()) {
CommonUITool.openErrorBox(getShell(), Messages.errMsgExecuteInResult);
return;
}
result.tblResult.forceFocus();
result.deleteRecord(result.tblResult, null);
}
});
insertSaveItem = new ToolItem(topLeftToolBar, SWT.PUSH);
result.insertSaveItem = insertSaveItem;
insertSaveItem.setToolTipText(Messages.insertCommit);
insertSaveItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_commit.png"));
insertSaveItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/query_commit_disabled.png"));
insertSaveItem.setEnabled(false);
insertSaveItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (!checkConnection()) {
CommonUITool.openErrorBox(getShell(), Messages.errMsgExecuteInResult);
return;
}
if (result.getQueryEditor().isActive()) {
CommonUITool.openWarningBox(Messages.msgActiveTran);
return;
}
if (!CommonUITool.openConfirmBox(getShell(), (Messages.msgCommitEdited))) {
return;
}
try {
if (result.saveInsertedUpdatedDeletedRecords()) {
insertSaveItem.setEnabled(false);
result.rollbackModifiedItem.setEnabled(false);
result.swRecordItem.setSelection(false);
}
result.swRecordItem.setSelection(false);
result.insertRecordItem.setEnabled(false);
result.delRecordItem.setEnabled(false);
result.setEditMode(false);
} catch (ParamSetException e) {
if (e.getParameter() != null && !StringUtil.isEmpty(e.getParameter().getDataType())) {
CommonUITool.openErrorBox(Messages.bind(Messages.errTextTypeNotMatch, e.getParameter().getDataType()) + StringUtil.NEWLINE + e.getLocalizedMessage());
} else {
CommonUITool.openErrorBox(getShell(), e.getLocalizedMessage());
}
} catch (SQLException e) {
e.printStackTrace();
CommonUITool.openErrorBox(getShell(), e.getErrorCode() + StringUtil.NEWLINE + e.getMessage());
/*Can't edit any data if necessary*/
// result.setEditMode(false);
// delRecordItem.setEnabled(false);
// insertRecordItem.setEnabled(false);
// insertSaveItem.setEnabled(false) ;
// swRecordItem.setEnabled(false);
// rollbackModifiedItem.setEnabled(false);
result.getTblResult().setBackground(BACKGROUND_DIRTY);
}
}
});
rollbackModifiedItem = new ToolItem(topLeftToolBar, SWT.PUSH);
result.rollbackModifiedItem = rollbackModifiedItem;
rollbackModifiedItem.setToolTipText(Messages.insertRollback);
rollbackModifiedItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_rollback.png"));
rollbackModifiedItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/query_rollback_disabled.png"));
rollbackModifiedItem.setEnabled(false);
rollbackModifiedItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (!CommonUITool.openConfirmBox(getShell(), (Messages.msgRollbackEdited))) {
return;
}
result.tblResult.forceFocus();
insertSaveItem.setEnabled(false);
rollbackModifiedItem.setEnabled(false);
result.clearModifiedLog();
QueryInfo queryInfo = result.getQueryInfo();
queryInfo.setCurrentPage(queryInfo.getCurrentPage());
result.makeItem();
result.updateActions();
result.swRecordItem.setSelection(false);
result.insertRecordItem.setEnabled(false);
result.delRecordItem.setEnabled(false);
result.setEditMode(false);
result.tblResult.setBackground(BACKGROUND_NORMAL);
}
});
if (!isMutliQuery) {
new ToolItem(topLeftToolBar, SWT.SEPARATOR);
copyInsertSqlFromRecordsItem = new ToolItem(topLeftToolBar, SWT.PUSH);
copyInsertSqlFromRecordsItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/record_to_insert.png"));
copyInsertSqlFromRecordsItem.setToolTipText(Messages.makeInsertFromSelectedRecord);
copyInsertSqlFromRecordsItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
if (editor == null) {
return;
}
String text = editor.getQueryExecuter().makeInsertQueryWithSelectedRecords();
if (StringUtil.isEmpty(text)) {
CommonUITool.openErrorBox(getShell(), Messages.canNotMakeQueryBecauseNoSelected);
return;
}
CommonUITool.copyContentToClipboard(text);
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
copyUpdateSqlFromRecordsItem = new ToolItem(topLeftToolBar, SWT.PUSH);
copyUpdateSqlFromRecordsItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/record_to_update.png"));
copyUpdateSqlFromRecordsItem.setToolTipText(Messages.makeUpdateFromSelectedRecord);
copyUpdateSqlFromRecordsItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
if (editor == null) {
return;
}
String text = editor.getQueryExecuter().makeUpdateQueryWithSelectedRecords();
if (StringUtil.isEmpty(text)) {
CommonUITool.openErrorBox(getShell(), Messages.canNotMakeQueryBecauseNoSelected);
return;
}
CommonUITool.copyContentToClipboard(text);
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
}
new ToolItem(topLeftToolBar, SWT.SEPARATOR);
final ToolItem exportDataItem = new ToolItem(topLeftToolBar, SWT.PUSH);
exportDataItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/table_data_export.png"));
exportDataItem.setToolTipText(Messages.msgExportAllQueryResults);
exportDataItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
CTabItem[] items = queryResultTabFolder.getItems();
if (items == null || items.length == 0) {
return;
}
List<QueryExecuter> qeList = new ArrayList<QueryExecuter>();
for (CTabItem item : items) {
if (!(item.getData() instanceof QueryExecuter)) {
continue;
}
QueryExecuter qe = (QueryExecuter) item.getData();
qeList.add(qe);
}
if (qeList.isEmpty()) {
return;
}
ExportQueryResultDialog dialog = new ExportQueryResultDialog(getShell(), qeList);
dialog.open();
}
});
new ToolItem(topLeftToolBar, SWT.SEPARATOR);
final ToolItem showLogItem = new ToolItem(topLeftToolBar, SWT.PUSH);
showLogItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_panel_down.png"));
showLogItem.setToolTipText(Messages.tooltip_qedit_log_show_hide);
showLogItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (tableLogSash.getMaximizedControl() == null) {
tableLogSash.setMaximizedControl(resultContainer);
showLogItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_panel_up.png"));
tableLogSash.layout(true);
} else {
tableLogSash.setMaximizedControl(null);
showLogItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_panel_down.png"));
tableLogSash.layout(true);
}
}
});
new ToolItem(topLeftToolBar, SWT.SEPARATOR);
viewForm.setContent(tableLogSash);
viewForm.setTopRight(topRightToolBar);
viewForm.setTopLeft(topLeftToolBar);
final QueryTableTabItem queryTableTabItem = new QueryTableTabItem(parentFolder, SWT.NONE);
queryTableTabItem.setText(Messages.qedit_result + (result.idx + 1));
queryTableTabItem.setControl(viewForm);
queryTableTabItem.setData(result);
queryTableTabItem.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
InfoWindowManager.getInstance().updateContent(editor);
}
});
parentFolder.setSelection(queryTableTabItem);
tableSelectSupport.addSelectChangeListener(new ISelectionChangeListener() {
@SuppressWarnings("unchecked")
public void selectionChanged(SelectionChangeEvent event) {
boolean active = event.selectedArray.length > 0;
boolean canEdit = active && result.getEditable() && result.isEditMode();
if (delRecordItem != null) {
delRecordItem.setEnabled(canEdit);
}
if (copyInsertSqlFromRecordsItem != null) {
copyInsertSqlFromRecordsItem.setEnabled(active);
}
if (copyUpdateSqlFromRecordsItem != null) {
copyUpdateSqlFromRecordsItem.setEnabled(active);
}
/*TOOLS-3632 Add calculation info*/
int count = event.selectedArray.length;
BigDecimal sum = new BigDecimal(0);
BigDecimal average = null;
int numericCount = 0;
QueryResultTableCalcInfo queryResultTableCalcInfo = null;
StatusLineContrItem statusCont = LayoutManager.getInstance().getStatusLineContrItem();
if (count > 1) {
for (Point p : event.selectedArray) {
TableColumn column = result.tblResult.getColumn(p.x);
if (column == null) {
continue;
}
ColumnInfo columnInfo = (ColumnInfo) column.getData();
if (columnInfo == null) {
continue;
}
String dataType = columnInfo.getType();
if (!DataType.isNumberType(dataType)) {
continue;
}
TableItem item = result.tblResult.getItem(p.y);
if (item == null || item.getData() == null) {
continue;
}
Map<String, CellValue> dataMap = (Map<String, CellValue>) item.getData();
CellValue cellValue = dataMap.get(Integer.toString(p.x));
if (cellValue != null && cellValue.getValue() != null) {
numericCount++;
Object value = cellValue.getValue();
if (value instanceof Integer) {
sum = sum.add(new BigDecimal((Integer) value));
} else if (value instanceof Short) {
sum = sum.add(new BigDecimal((Short) value));
} else if (value instanceof Long) {
sum = sum.add(new BigDecimal((Long) value));
} else if (value instanceof Float) {
sum = sum.add(new BigDecimal((Float) value));
} else if (value instanceof Double) {
sum = sum.add(new BigDecimal((Double) value));
} else if (value instanceof BigDecimal) {
sum = sum.add((BigDecimal) value);
}
}
}
if (numericCount > 0) {
average = sum.divide(new BigDecimal(numericCount), 3, RoundingMode.HALF_UP);
queryResultTableCalcInfo = new QueryResultTableCalcInfo(count, average, sum);
} else {
queryResultTableCalcInfo = new QueryResultTableCalcInfo(count);
}
}
queryTableTabItem.setQueryResultTableCalcInfo(queryResultTableCalcInfo);
InfoWindowManager.getInstance().updateContent(editor);
statusCont.changeStuatusLineForViewOrEditPart(editor.getSelectedDatabase(), editor);
}
});
}
use of org.eclipse.swt.layout.FormLayout in project cubrid-manager by CUBRID.
the class TuneModeResultComposite method createQueryCompareTab.
private void createQueryCompareTab(Composite comp) {
Composite composite = new Composite(comp, SWT.None);
composite.setLayout(new GridLayout());
composite.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
Composite topComposite = new Composite(composite, SWT.None);
topComposite.setLayout(new FormLayout());
topComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, 25));
Composite leftTopComposite = new Composite(topComposite, SWT.None);
FormData leftTopData = new FormData();
leftTopData.top = new FormAttachment(0, 0);
leftTopData.bottom = new FormAttachment(100, 0);
leftTopData.left = new FormAttachment(0, 0);
leftTopData.right = new FormAttachment(50, 0);
leftTopComposite.setLayoutData(leftTopData);
leftTopComposite.setLayout(new GridLayout(1, false));
Composite rightTopComposite = new Composite(topComposite, SWT.None);
FormData rightTopData = new FormData();
rightTopData.top = new FormAttachment(0, 0);
rightTopData.bottom = new FormAttachment(100, 0);
rightTopData.left = new FormAttachment(50, 0);
rightTopData.right = new FormAttachment(100, 0);
rightTopComposite.setLayoutData(rightTopData);
rightTopComposite.setLayout(new GridLayout(4, false));
useLeft = new Button(leftTopComposite, SWT.CHECK);
useLeft.setText(Messages.lblTuneModeOrgPlan);
useLeft.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
useLeft.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (useLeft.getSelection()) {
useRight.setSelection(false);
} else {
useRight.setSelection(true);
}
}
});
useLeft.setSelection(true);
useRight = new Button(rightTopComposite, SWT.CHECK);
useRight.setText(Messages.lblTuneModeNewPlan);
useRight.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
useRight.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (useRight.getSelection()) {
useLeft.setSelection(false);
} else {
useLeft.setSelection(true);
}
}
});
useRight.setSelection(false);
ToolBar leftToolBar = new ToolBar(rightTopComposite, SWT.None);
leftToolBar.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
Composite folderPlaceComposite = new Composite(rightTopComposite, SWT.None);
folderPlaceComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
ToolBar rightToolBar = new ToolBar(rightTopComposite, SWT.None);
rightToolBar.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 1, 1, -1, -1));
sqlModeItem = new ToolItem(rightToolBar, SWT.CHECK);
sqlModeItem.setImage(CommonUIPlugin.getImage("icons/queryplan/sql_compare.gif"));
sqlModeItem.setToolTipText(Messages.itemTooltipQuery);
//sqlModeItem.setText(Messages.lblTuneCompareQueryBtn);
sqlModeItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
updateCompareDisplayModel(DISPLAY_SQL);
}
});
textModelItem = new ToolItem(rightToolBar, SWT.CHECK);
textModelItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_explain_mode_raw.png"));
textModelItem.setToolTipText(Messages.tooltip_qedit_explain_display_mode);
//textModelItem.setText(Messages.lblPlanRawBtn);
textModelItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
updateCompareDisplayModel(DISPLAY_TEXT);
}
});
treeModelItem = new ToolItem(rightToolBar, SWT.CHECK);
treeModelItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_explain_mode_tree.png"));
treeModelItem.setToolTipText(Messages.tooltip_qedit_explain_display_mode);
//treeModelItem.setText(Messages.lblPlanTreeBtn);
treeModelItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
updateCompareDisplayModel(DISPLAY_TREE);
}
});
graphModelItem = new ToolItem(rightToolBar, SWT.CHECK);
graphModelItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_explain_mode_graph.png"));
graphModelItem.setToolTipText(Messages.tooltip_qedit_explain_display_mode);
//graphModelItem.setText(Messages.lblPlanGraph);
graphModelItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
updateCompareDisplayModel(DISPLAY_GRAPH);
}
});
Composite tablesComposite = new Composite(composite, SWT.None);
tablesComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, 60));
tablesComposite.setLayout(new FormLayout());
/*Left composite*/
Composite leftTableComposite = new Composite(tablesComposite, SWT.BORDER);
leftTableComposite.setLayout(new GridLayout());
FormData leftTableData = new FormData();
leftTableData.top = new FormAttachment(0, 0);
leftTableData.bottom = new FormAttachment(100, 0);
leftTableData.left = new FormAttachment(0, 0);
leftTableData.right = new FormAttachment(50, -2);
leftTableComposite.setLayoutData(leftTableData);
/*Right composite*/
Composite rightTableComposite = new Composite(tablesComposite, SWT.BORDER);
rightTableComposite.setLayout(new GridLayout());
FormData rightTabelData = new FormData();
rightTabelData.top = new FormAttachment(0, 0);
rightTabelData.bottom = new FormAttachment(100, 0);
rightTabelData.left = new FormAttachment(50, 2);
rightTabelData.right = new FormAttachment(100, 0);
rightTableComposite.setLayoutData(rightTabelData);
compareLeftTableViewer = new TableViewer(leftTableComposite, SWT.FULL_SELECTION);
compareLeftTableViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
compareLeftTableViewer.getTable().setHeaderVisible(true);
compareLeftTableViewer.getTable().setLinesVisible(false);
compareLeftTableViewer.setContentProvider(new TuneModeResultContentProvider());
compareLeftTableViewer.setLabelProvider(new TuneModeResultLabelProvider(compareLeftTableViewer, false));
TableColumn fetchColumnLeft = new TableColumn(compareLeftTableViewer.getTable(), SWT.None);
fetchColumnLeft.setText(Messages.columnFetches);
fetchColumnLeft.setWidth(60);
TableColumn dirtyColumnLeft = new TableColumn(compareLeftTableViewer.getTable(), SWT.None);
dirtyColumnLeft.setText(Messages.columnDirties);
dirtyColumnLeft.setWidth(60);
TableColumn ioReadColumnLeft = new TableColumn(compareLeftTableViewer.getTable(), SWT.None);
ioReadColumnLeft.setText(Messages.columnIORead);
ioReadColumnLeft.setWidth(80);
TableColumn ioWriteColumnLeft = new TableColumn(compareLeftTableViewer.getTable(), SWT.None);
ioWriteColumnLeft.setText(Messages.columnIOWrite);
ioWriteColumnLeft.setWidth(80);
TableColumn costColumnLeft = new TableColumn(compareLeftTableViewer.getTable(), SWT.None);
costColumnLeft.setText(Messages.columnCost);
costColumnLeft.setWidth(60);
compareRightTableViewer = new TableViewer(rightTableComposite, SWT.FULL_SELECTION);
compareRightTableViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
compareRightTableViewer.getTable().setHeaderVisible(true);
compareRightTableViewer.getTable().setLinesVisible(false);
compareRightTableViewer.setContentProvider(new TuneModeResultContentProvider());
compareRightTableViewer.setLabelProvider(new TuneModeResultLabelProvider(compareRightTableViewer, false));
TableColumn fetchColumnRight = new TableColumn(compareRightTableViewer.getTable(), SWT.None);
fetchColumnRight.setText(Messages.columnFetches);
fetchColumnRight.setWidth(60);
TableColumn dirtyColumnRight = new TableColumn(compareRightTableViewer.getTable(), SWT.None);
dirtyColumnRight.setText(Messages.columnDirties);
dirtyColumnRight.setWidth(60);
TableColumn ioReadColumnRight = new TableColumn(compareRightTableViewer.getTable(), SWT.None);
ioReadColumnRight.setText(Messages.columnIORead);
ioReadColumnRight.setWidth(80);
TableColumn ioWriteColumnRight = new TableColumn(compareRightTableViewer.getTable(), SWT.None);
ioWriteColumnRight.setText(Messages.columnIOWrite);
ioWriteColumnRight.setWidth(80);
TableColumn costColumnRight = new TableColumn(compareRightTableViewer.getTable(), SWT.None);
costColumnRight.setText(Messages.columnCost);
costColumnRight.setWidth(60);
queryPlanCompareSashForm = new SashForm(composite, SWT.VERTICAL);
queryPlanCompareSashForm.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
queryPlanCompareSashForm.setBackground(SASH_COLOR);
queryPlanCompareSashForm.setLayout(new GridLayout());
queryPlanCompareSashForm.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
queryPlanCompareSashForm.setSashWidth(0);
Composite textMergeComposite = new Composite(queryPlanCompareSashForm, SWT.None);
textMergeComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
textMergeComposite.setLayout(new FillLayout());
textMergeConfig = new CompareConfiguration();
textMergeConfig.setProperty(CompareConfiguration.SHOW_PSEUDO_CONFLICTS, Boolean.FALSE);
textMergeConfig.setProperty(CompareConfiguration.IGNORE_WHITESPACE, Boolean.TRUE);
textMergeConfig.setLeftEditable(false);
textMergeConfig.setRightEditable(false);
textMergeViewer = new TextMergeViewer(textMergeComposite, SWT.BORDER, textMergeConfig);
DiffNode queryDiffNode = new DiffNode(null, Differencer.CHANGE, null, new TextCompareInput(""), new TextCompareInput(""));
textMergeViewer.setInput(queryDiffNode);
Composite compareQueryPlanComposite = new Composite(queryPlanCompareSashForm, SWT.None);
compareQueryPlanComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
compareQueryPlanComposite.setLayout(new FormLayout());
leftComparePlanComposite = new QueryPlanComposite(compareQueryPlanComposite, SWT.BORDER, null, databaseInfo);
FormData leftData = new FormData();
leftData.top = new FormAttachment(0, 0);
leftData.bottom = new FormAttachment(100, 0);
leftData.left = new FormAttachment(0, 0);
leftData.right = new FormAttachment(50, 0);
leftComparePlanComposite.setLayoutData(leftData);
rightComparePlanComposite = new QueryPlanComposite(compareQueryPlanComposite, SWT.BORDER, null, databaseInfo);
FormData rightData = new FormData();
rightData.top = new FormAttachment(0, 0);
rightData.bottom = new FormAttachment(100, 0);
rightData.left = new FormAttachment(50, 0);
rightData.right = new FormAttachment(100, 0);
rightComparePlanComposite.setLayoutData(rightData);
queryPlanCompareSashForm.setWeights(new int[] { 100, 0 });
updateCompareDisplayModel(DISPLAY_TREE);
}
Aggregations