List of usage examples for org.eclipse.jface.dialogs IDialogConstants HORIZONTAL_SPACING
int HORIZONTAL_SPACING
To view the source code for org.eclipse.jface.dialogs IDialogConstants HORIZONTAL_SPACING.
Click Source Link
From source file:org.summer.dsl.ui.codetemplates.ui.preferences.EditTemplateDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite ancestor) { Composite parent = new Composite(ancestor, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2;/*w w w . j av a2s . c om*/ layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); parent.setLayout(layout); parent.setLayoutData(new GridData(GridData.FILL_BOTH)); ModifyListener listener = new ModifyListener() { public void modifyText(ModifyEvent e) { doTextWidgetChanged(e.widget); } }; if (fIsNameModifiable) { createLabel(parent, TemplateDialogMessages.EditTemplateDialog_name); Composite composite = new Composite(parent, SWT.NONE); composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); layout = new GridLayout(); layout.numColumns = 4; layout.marginWidth = 0; layout.marginHeight = 0; composite.setLayout(layout); fNameText = createText(composite); createLabel(composite, TemplateDialogMessages.EditTemplateDialog_context); fContextCombo = new Combo(composite, SWT.READ_ONLY); fContextCombo.setVisibleItemCount(30); // default for (int i = 0; i < fContextTypes.length; i++) { fContextCombo.add(fContextTypes[i][1]); } fContextCombo.addModifyListener(listener); fAutoInsertCheckbox = createCheckbox(composite, TemplateDialogMessages.EditTemplateDialog_autoinsert); fAutoInsertCheckbox.setSelection(fTemplate.isAutoInsertable()); } createLabel(parent, TemplateDialogMessages.EditTemplateDialog_description); int descFlags = fIsNameModifiable ? SWT.BORDER : SWT.BORDER | SWT.READ_ONLY; fDescriptionText = new Text(parent, descFlags); fDescriptionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fDescriptionText.addModifyListener(listener); Label patternLabel = createLabel(parent, TemplateDialogMessages.EditTemplateDialog_pattern); patternLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); fPatternEditor = createEditor(parent); Label filler = new Label(parent, SWT.NONE); filler.setLayoutData(new GridData()); Composite composite = new Composite(parent, SWT.NONE); layout = new GridLayout(); layout.marginWidth = 0; layout.marginHeight = 0; composite.setLayout(layout); composite.setLayoutData(new GridData()); fInsertVariableButton = new Button(composite, SWT.NONE); fInsertVariableButton.setLayoutData(getButtonGridData()); fInsertVariableButton.setText(TemplateDialogMessages.EditTemplateDialog_insert_variable); fInsertVariableButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { fPatternEditor.getTextWidget().setFocus(); fPatternEditor.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS); } public void widgetDefaultSelected(SelectionEvent e) { } }); fDescriptionText.setText(fTemplate.getDescription()); if (fIsNameModifiable) { fNameText.setText(fTemplate.getName()); fNameText.addModifyListener(listener); fContextCombo.select(getIndex(fTemplate.getContextTypeId())); } else { fPatternEditor.getControl().setFocus(); } applyDialogFont(parent); return composite; }
From source file:org.summer.sdt.internal.ui.dialogs.SortMembersMessageDialog.java
License:Open Source License
@Override protected Control createMessageArea(Composite parent) { initializeDialogUnits(parent);/*from www .j a v a2 s.c o m*/ Composite messageComposite = new Composite(parent, SWT.NONE); messageComposite.setFont(parent.getFont()); GridLayout layout = new GridLayout(); layout.numColumns = 1; layout.marginHeight = 0; layout.marginWidth = 0; layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); messageComposite.setLayout(layout); messageComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); createLinkControl(messageComposite); fNotSortAllRadio.doFillIntoGrid(messageComposite, 1); LayoutUtil.setHorizontalIndent(fNotSortAllRadio.getSelectionButton(null)); fSortAllRadio.doFillIntoGrid(messageComposite, 1); LayoutUtil.setHorizontalIndent(fSortAllRadio.getSelectionButton(null)); final Composite warningComposite = new Composite(messageComposite, SWT.NONE); layout = new GridLayout(); layout.numColumns = 2; layout.marginWidth = 0; layout.marginHeight = 0; warningComposite.setLayout(layout); warningComposite.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false)); warningComposite.setFont(messageComposite.getFont()); Image image = Dialog.getImage(Dialog.DLG_IMG_MESSAGE_WARNING); final Label imageLabel1 = new Label(warningComposite, SWT.LEFT | SWT.WRAP); imageLabel1.setImage(image); imageLabel1.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 1, 1)); final Label label = new Label(warningComposite, SWT.WRAP); label.setText(DialogsMessages.SortMembersMessageDialog_sort_warning_label); GridData gridData = new GridData(GridData.FILL, GridData.CENTER, true, false, 1, 1); gridData.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); label.setLayoutData(gridData); label.setFont(warningComposite.getFont()); fNotSortAllRadio.setDialogFieldListener(new IDialogFieldListener() { public void dialogFieldChanged(DialogField field) { imageLabel1.setEnabled(!fNotSortAllRadio.isSelected()); label.setEnabled(!fNotSortAllRadio.isSelected()); } }); imageLabel1.setEnabled(!fNotSortAllRadio.isSelected()); label.setEnabled(!fNotSortAllRadio.isSelected()); return messageComposite; }
From source file:org.summer.sdt.internal.ui.preferences.EditTemplateDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite ancestor) { Composite parent = new Composite(ancestor, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2;/*from ww w . j a v a2 s.co m*/ layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); parent.setLayout(layout); parent.setLayoutData(new GridData(GridData.FILL_BOTH)); ModifyListener listener = new ModifyListener() { public void modifyText(ModifyEvent e) { doTextWidgetChanged(e.widget); } }; if (fIsNameModifiable) { createLabel(parent, PreferencesMessages.EditTemplateDialog_name); Composite composite = new Composite(parent, SWT.NONE); composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); layout = new GridLayout(); layout.numColumns = 4; layout.marginWidth = 0; layout.marginHeight = 0; composite.setLayout(layout); fNameText = createText(composite); fNameText.addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { } public void focusLost(FocusEvent e) { if (fSuppressError) { fSuppressError = false; updateStatusAndButtons(); } } }); BidiUtils.applyBidiProcessing(fNameText, BidiUtils.BTD_DEFAULT); createLabel(composite, PreferencesMessages.EditTemplateDialog_context); fContextCombo = new Combo(composite, SWT.READ_ONLY); SWTUtil.setDefaultVisibleItemCount(fContextCombo); for (int i = 0; i < fContextTypes.length; i++) { fContextCombo.add(fContextTypes[i][1]); } fContextCombo.addModifyListener(listener); fAutoInsertCheckbox = createCheckbox(composite, PreferencesMessages.EditTemplateDialog_autoinsert); fAutoInsertCheckbox.setSelection(fTemplate.isAutoInsertable()); } createLabel(parent, PreferencesMessages.EditTemplateDialog_description); int descFlags = fIsNameModifiable ? SWT.BORDER : SWT.BORDER | SWT.READ_ONLY; fDescriptionText = new Text(parent, descFlags); fDescriptionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fDescriptionText.addModifyListener(listener); BidiUtils.applyBidiProcessing(fDescriptionText, BidiUtils.BTD_DEFAULT); Label patternLabel = createLabel(parent, PreferencesMessages.EditTemplateDialog_pattern); patternLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); fPatternEditor = createEditor(parent); Label filler = new Label(parent, SWT.NONE); filler.setLayoutData(new GridData()); Composite composite = new Composite(parent, SWT.NONE); layout = new GridLayout(); layout.marginWidth = 0; layout.marginHeight = 0; composite.setLayout(layout); composite.setLayoutData(new GridData()); fInsertVariableButton = new Button(composite, SWT.NONE); fInsertVariableButton.setLayoutData(getButtonGridData()); fInsertVariableButton.setText(PreferencesMessages.EditTemplateDialog_insert_variable); fInsertVariableButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { fPatternEditor.getTextWidget().setFocus(); fPatternEditor.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS); } public void widgetDefaultSelected(SelectionEvent e) { } }); fDescriptionText.setText(fTemplate.getDescription()); if (fIsNameModifiable) { fNameText.setText(fTemplate.getName()); fNameText.addModifyListener(listener); fContextCombo.select(getIndex(fTemplate.getContextTypeId())); } else { fPatternEditor.getControl().setFocus(); } initializeActions(); applyDialogFont(parent); return composite; }
From source file:org.summer.sdt.internal.ui.refactoring.reorg.RenameTypeWizardSimilarElementsOptionsDialog.java
License:Open Source License
@Override protected Control createMessageArea(Composite parent) { initializeDialogUnits(parent);// w ww . j av a2 s .c o m Composite messageComposite = new Composite(parent, SWT.NONE); messageComposite.setFont(parent.getFont()); GridLayout layout = new GridLayout(); layout.numColumns = 1; layout.marginHeight = 0; layout.marginWidth = 0; layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); messageComposite.setLayout(layout); messageComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); Label infoLabel = new Label(messageComposite, SWT.WRAP); infoLabel.setText(RefactoringMessages.RenameTypeWizardSimilarElementsOptionsDialog_select_strategy); GridData gd = new GridData(GridData.FILL, GridData.CENTER, true, false); gd.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); infoLabel.setLayoutData(gd); infoLabel.setFont(parent.getFont()); fExactStrategyRadio = new SelectionButtonDialogField(SWT.RADIO); fExactStrategyRadio .setLabelText(RefactoringMessages.RenameTypeWizardSimilarElementsOptionsDialog_strategy_1); fExactStrategyRadio.doFillIntoGrid(messageComposite, 1); fExactStrategyRadio.setSelection(fSelectedStrategy == RenamingNameSuggestor.STRATEGY_EXACT); LayoutUtil.setHorizontalIndent(fExactStrategyRadio.getSelectionButton(null)); fEmbeddedStrategyRadio = new SelectionButtonDialogField(SWT.RADIO); fEmbeddedStrategyRadio .setLabelText(RefactoringMessages.RenameTypeWizardSimilarElementsOptionsDialog_strategy_2); fEmbeddedStrategyRadio.doFillIntoGrid(messageComposite, 1); fEmbeddedStrategyRadio.setSelection(fSelectedStrategy == RenamingNameSuggestor.STRATEGY_EMBEDDED); LayoutUtil.setHorizontalIndent(fEmbeddedStrategyRadio.getSelectionButton(null)); fSuffixStrategyRadio = new SelectionButtonDialogField(SWT.RADIO); fSuffixStrategyRadio .setLabelText(RefactoringMessages.RenameTypeWizardSimilarElementsOptionsDialog_strategy_3); fSuffixStrategyRadio.doFillIntoGrid(messageComposite, 1); fSuffixStrategyRadio.setSelection(fSelectedStrategy == RenamingNameSuggestor.STRATEGY_SUFFIX); LayoutUtil.setHorizontalIndent(fSuffixStrategyRadio.getSelectionButton(null)); final Composite warningComposite = new Composite(messageComposite, SWT.NONE); layout = new GridLayout(); layout.numColumns = 2; layout.marginWidth = 0; layout.marginHeight = 0; warningComposite.setLayout(layout); warningComposite.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false)); warningComposite.setFont(messageComposite.getFont()); Image image = Dialog.getImage(Dialog.DLG_IMG_MESSAGE_WARNING); fWarningImageLabel = new Label(warningComposite, SWT.LEFT | SWT.WRAP); fWarningImageLabel.setImage(image); fWarningImageLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 1, 1)); fWarningLabel = new Label(warningComposite, SWT.WRAP); fWarningLabel.setText(RefactoringMessages.RenameTypeWizardSimilarElementsOptionsDialog_warning_short_names); GridData gridData = new GridData(GridData.FILL, GridData.CENTER, true, false, 1, 1); gridData.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); fWarningLabel.setLayoutData(gridData); fWarningLabel.setFont(warningComposite.getFont()); fExactStrategyRadio.setDialogFieldListener(new IDialogFieldListener() { public void dialogFieldChanged(DialogField field) { updateLabel(); fSelectedStrategy = RenamingNameSuggestor.STRATEGY_EXACT; } }); fEmbeddedStrategyRadio.setDialogFieldListener(new IDialogFieldListener() { public void dialogFieldChanged(DialogField field) { updateLabel(); fSelectedStrategy = RenamingNameSuggestor.STRATEGY_EMBEDDED; } }); fSuffixStrategyRadio.setDialogFieldListener(new IDialogFieldListener() { public void dialogFieldChanged(DialogField field) { updateLabel(); fSelectedStrategy = RenamingNameSuggestor.STRATEGY_SUFFIX; } }); updateLabel(); return messageComposite; }
From source file:org.summer.sdt.internal.ui.text.java.ContentAssistProcessor.java
License:Open Source License
/** * Informs the user about the fact that there are no enabled categories in the default content * assist set and shows a link to the preferences. * * @return <code>true</code> if the default should be restored * @since 3.3//from ww w.j a v a 2 s. co m */ private boolean informUserAboutEmptyDefaultCategory() { if (OptionalMessageDialog.isDialogEnabled(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY)) { final Shell shell = JavaPlugin.getActiveWorkbenchShell(); String title = JavaTextMessages.ContentAssistProcessor_all_disabled_title; String message = JavaTextMessages.ContentAssistProcessor_all_disabled_message; // see PreferencePage#createControl for the 'defaults' label final String restoreButtonLabel = JFaceResources.getString("defaults"); //$NON-NLS-1$ final String linkMessage = Messages.format( JavaTextMessages.ContentAssistProcessor_all_disabled_preference_link, LegacyActionTools.removeMnemonics(restoreButtonLabel)); final int restoreId = IDialogConstants.CLIENT_ID + 10; final int settingsId = IDialogConstants.CLIENT_ID + 11; final OptionalMessageDialog dialog = new OptionalMessageDialog(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY, shell, title, null /* default image */, message, MessageDialog.WARNING, new String[] { restoreButtonLabel, IDialogConstants.CLOSE_LABEL }, 1) { /* * @see org.summer.sdt.internal.ui.dialogs.OptionalMessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite) */ @Override protected Control createCustomArea(Composite composite) { // wrap link and checkbox in one composite without space Composite parent = new Composite(composite, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; layout.verticalSpacing = 0; parent.setLayout(layout); Composite linkComposite = new Composite(parent, SWT.NONE); layout = new GridLayout(); layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); linkComposite.setLayout(layout); Link link = new Link(linkComposite, SWT.NONE); link.setText(linkMessage); link.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { setReturnCode(settingsId); close(); } }); GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false); gridData.widthHint = this.getMinimumMessageWidth(); link.setLayoutData(gridData); // create checkbox and "don't show this message" prompt super.createCustomArea(parent); return parent; } /* * @see org.eclipse.jface.dialogs.MessageDialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) */ @Override protected void createButtonsForButtonBar(Composite parent) { Button[] buttons = new Button[2]; buttons[0] = createButton(parent, restoreId, restoreButtonLabel, false); buttons[1] = createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, true); setButtons(buttons); } }; int returnValue = dialog.open(); if (restoreId == returnValue || settingsId == returnValue) { if (restoreId == returnValue) { IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore(); store.setToDefault(PreferenceConstants.CODEASSIST_CATEGORY_ORDER); store.setToDefault(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES); } if (settingsId == returnValue) PreferencesUtil .createPreferenceDialogOn(shell, "org.summer.sdt.ui.preferences.CodeAssistPreferenceAdvanced", null, null) //$NON-NLS-1$ .open(); fComputerRegistry.reload(); return true; } } return false; }
From source file:org.talend.core.repository.ui.dialog.DuplicateDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); composite.setLayout(layout);//from w w w .java2 s .co m composite.setLayoutData(new GridData(GridData.FILL_BOTH)); super.createMessageWidget(parent, composite); super.createInputWidget(composite); typeGroup = new Composite(composite, SWT.NONE); GridLayout typeLayout = new GridLayout(); typeLayout.numColumns = 6; typeGroup.setLayout(typeLayout); typeGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); jobTypeCombo = new LabelledCombo(typeGroup, "Job Type:", "job type", JobType.getJobTypeToDispaly(), 2, //$NON-NLS-1$//$NON-NLS-2$ true); frameworkCombo = new LabelledCombo(typeGroup, "Framework:", "framework", new String[0], 2, true); //$NON-NLS-1$//$NON-NLS-2$ super.createErrorMessageWidget(composite); applyDialogFont(composite); // add listener addListener(); // init init(); return parent; }
From source file:org.talend.core.ui.workspace.ChooseWorkspaceDialog.java
License:Open Source License
/** * The main area of the dialog is just a row with the current selection information and a drop-down of the most * recently used workspaces./* w w w.ja va2s . co m*/ */ private void createWorkspaceBrowseRow(Composite parent) { Composite panel = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(3, false); layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); panel.setLayout(layout); panel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); panel.setFont(parent.getFont()); Label label = new Label(panel, SWT.NONE); label.setText(Messages.getString("WorkspaceDlg.workspace.label")); //$NON-NLS-1$ text = new Combo(panel, SWT.BORDER | SWT.LEAD | SWT.DROP_DOWN); text.setFocus(); text.setLayoutData(new GridData(400, SWT.DEFAULT)); text.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { Button okButton = getButton(Window.OK); if (okButton != null && !okButton.isDisposed()) { boolean nonWhitespaceFound = false; String characters = getWorkspaceLocation(); for (int i = 0; !nonWhitespaceFound && i < characters.length(); i++) { if (!Character.isWhitespace(characters.charAt(i))) { nonWhitespaceFound = true; } } okButton.setEnabled(nonWhitespaceFound); } } }); setInitialTextValues(text); Button browseButton = new Button(panel, SWT.PUSH); browseButton.setText(Messages.getString("WorkspaceDlg.browse.button")); //$NON-NLS-1$ setButtonLayoutData(browseButton); GridData data = (GridData) browseButton.getLayoutData(); data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_END; browseButton.setLayoutData(data); browseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.SHEET); dialog.setText(Messages.getString("WorkspaceDlg.browse.folder.title"));//$NON-NLS-1$ dialog.setMessage(Messages.getString("WorkspaceDlg.browse.folder.title"));//$NON-NLS-1$ dialog.setFilterPath(getInitialBrowsePath()); String dir = dialog.open(); if (dir != null) { text.setText(TextProcessor.process(dir)); } } }); }
From source file:org.talend.dataprofiler.common.ui.dialog.AbstractJarSelectDialog.java
License:Open Source License
/** * Adds the selection and deselection buttons to the dialog. * //from w w w .j a v a 2 s . c o m * @param composite the parent composite * @return Composite the composite the buttons were created in. */ protected Composite createButtons(final Composite composite, final boolean isSelect) { Composite buttonComposite = new Composite(composite, SWT.RIGHT); buttonComposite.setBackground(composite.getBackground()); GridLayout layout = new GridLayout(); layout.numColumns = 0; layout.marginWidth = 0; layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); buttonComposite.setLayout(layout); buttonComposite.setFont(composite.getFont()); GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL); data.grabExcessHorizontalSpace = true; buttonComposite.setLayoutData(data); Button selectButton = createButton(buttonComposite, IDialogConstants.SELECT_ALL_ID, WorkbenchMessages.CheckedTreeSelectionDialog_select_all, false); SelectionListener listener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Object[] viewerElements = fContentProvider.getElements(fInput); if (fContainerMode) { if (isSelect) { fViewer.setCheckedElements(viewerElements); // ADD msjian 2011-8-9 TDQ-3199 fixed: Make it convenient to delete the jar which is used // already. handleChecked(); handleClassNameFromJarFile(); // ADD end } else { fManageViewer.setCheckedElements(viewerElements); } } else { for (Object viewerElement : viewerElements) { if (isSelect) { fViewer.setSubtreeChecked(viewerElement, true); } else { fManageViewer.setSubtreeChecked(viewerElement, true); } } } updateOKStatus(); } }; selectButton.addSelectionListener(listener); Button deselectButton = createButton(buttonComposite, IDialogConstants.DESELECT_ALL_ID, WorkbenchMessages.CheckedTreeSelectionDialog_deselect_all, false); listener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (isSelect) { fViewer.setCheckedElements(new Object[0]); // ADD msjian 2011-8-9 TDQ-3199 fixed: Make it convenient to delete the jar which is used // already. handleChecked(); handleClassNameFromJarFile(); // ADD end } else { fManageViewer.setCheckedElements(new Object[0]); } updateOKStatus(); } }; deselectButton.addSelectionListener(listener); if (!isSelect) { final Composite dialogComposite = composite; Button addButton = createButton(buttonComposite, 22, Messages.getString("AbstractJarSelectDialog.add"), //$NON-NLS-1$ false); SelectionListener listenerAdd = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { FileDialog dialog = new FileDialog(dialogComposite.getShell(), SWT.NONE | SWT.MULTI); dialog.setFilterExtensions(new String[] { "*.jar" }); //$NON-NLS-1$ String path = dialog.open(); if (path != null) { String[] fileNames = dialog.getFileNames(); for (String name : fileNames) { IPath filePath = new Path(path); filePath = filePath.removeLastSegments(1).append(name); // TDQ-7451 Replace File copy with eclipse IFile create.make svn could syn and control. IFile targetFile = ResourceManager.getUDIJarFolder().getFile(filePath.lastSegment()); createIFileFromFile(filePath.toFile(), targetFile, getDescriptionMessage(name)); } } // MOD msjian 2011-7-14 22092 feature: Java UDI: not convinient to delete udi jar files fViewer.refresh(); fManageViewer.refresh(); fViewer.setInput(ResourceManager.getUDIJarFolder()); fManageViewer.setInput(ResourceManager.getUDIJarFolder()); fIsEmpty = evaluateIfTreeEmpty(fInput); // getTreeViewer().setCheckedElements(new Object[0]); updateOKStatus(); } }; addButton.addSelectionListener(listenerAdd); Button delButton = createButton(buttonComposite, 23, Messages.getString("AbstractJarSelectDialog.delete"), //$NON-NLS-1$ false); SelectionListener listenerDel = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { for (Object delFile : fManageViewer.getCheckedElements()) { // Object delFile = manageSelectList.get(i); if (delFile instanceof File) { // MOD msjian 2011-8-9 TDQ-3199 fixed: Make it convenient to delete the jar which is used // already. ReturnCode rc = checkJarDependency((File) delFile); if (selectedJars.containsKey(delFile)) { rc.setOk(false); rc.setMessage(getFileHasBeenSelectedMessages(delFile)); } // MOD end if (rc.isOk()) { boolean delete = ((File) delFile).delete(); if (!delete) { MessageDialog.openWarning(getParentShell(), Messages.getString("AbstractJarSelectDialog.delete"), //$NON-NLS-1$ Messages.getString("AbstractJarSelectDialog.deleteFail")); //$NON-NLS-1$ } } else { MessageDialog.openWarning(getParentShell(), Messages.getString("AbstractJarSelectDialog.warning"), rc.getMessage()); //$NON-NLS-1$ } } refreshWorkspace(); } // MOD msjian 2011-7-14 22092 feature: Java UDI: not convinient to delete udi jar files fViewer.refresh(); fManageViewer.refresh(); fIsEmpty = evaluateIfTreeEmpty(fInput); updateOKStatus(); } }; delButton.addSelectionListener(listenerDel); } else { createOKButton(buttonComposite); Button cancelButton = createButton(buttonComposite, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); SelectionListener listenerCancel = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { cancelPressed(); } }; cancelButton.addSelectionListener(listenerCancel); // TDQ-3556 ~ } return buttonComposite; }
From source file:org.talend.designer.core.ui.dialog.HelpAvailableDialog.java
License:Open Source License
@Override protected Control createButtonBar(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); // create a layout with spacing and margins appropriate for the font // size./* w w w . j a v a 2s. c om*/ GridLayout layout = new GridLayout(); layout.numColumns = 0; // this is incremented by createButton layout.makeColumnsEqualWidth = true; layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); composite.setLayout(layout); GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_CENTER); composite.setLayoutData(data); composite.setFont(parent.getFont()); // Add the buttons to the button bar. createButtonsForButtonBar(composite); return composite; }
From source file:org.talend.designer.core.ui.editor.update.UpdateDetectionDialog.java
License:Open Source License
private Composite createBottomButtonArea(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout gridLayout = new GridLayout(); gridLayout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING * 4); composite.setLayout(gridLayout);/*from www. j a v a2 s . c o m*/ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END)); // expand Button expandButton = createButton(composite, 99, Messages.getString("UpdateDetectionDialog.Expand"), //$NON-NLS-1$ false); expandButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (getViewer() != null) { getViewer().expandAll(); } } }); // collapse Button collapseButton = createButton(composite, 98, Messages.getString("UpdateDetectionDialog.Collapse"), //$NON-NLS-1$ false); collapseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (getViewer() != null) { getViewer().collapseAll(); } } }); if (!isOnlySimpleShow() && canDeselect) { // "select all" button // selectButton = createButton(composite, IDialogConstants.SELECT_ALL_ID, // WorkbenchMessages.SelectionDialog_selectLabel, // false); selectButton = createButton(composite, IDialogConstants.SELECT_ALL_ID, Messages.getString("WorkbenchMessages.SelectionDialog_selectLabel"), false); //$NON-NLS-1$ // init label; if (getViewerHelper() != null) { getViewerHelper().refreshSelectButton(); } selectButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (getViewerHelper() != null) { boolean state = false; // if (!isJobReadOnly && // WorkbenchMessages.SelectionDialog_selectLabel.equals(selectButton.getText())) { if (!isJobReadOnly && Messages.getString("WorkbenchMessages.SelectionDialog_selectLabel").equals( //$NON-NLS-1$ selectButton.getText())) { state = true; } getViewerHelper().selectAll(state); } } }); } return composite; }