List of usage examples for org.eclipse.jface.dialogs IDialogConstants BUTTON_WIDTH
int BUTTON_WIDTH
To view the source code for org.eclipse.jface.dialogs IDialogConstants BUTTON_WIDTH.
Click Source Link
From source file:org.eclipse.tcf.internal.debug.ui.commands.MemoryMapWidget.java
License:Open Source License
private void createMapButtons(Composite parent) { Font font = parent.getFont(); Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 0;//from w w w .ja v a 2 s . c o m layout.marginWidth = 0; composite.setFont(font); composite.setLayout(layout); composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); Menu menu = new Menu(map_table); SelectionAdapter sel_adapter = null; final Button button_add = new Button(composite, SWT.PUSH); button_add.setText(" &Add... "); //$NON-NLS-1$ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); PixelConverter converter = new PixelConverter(button_add); gd.widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); button_add.setLayoutData(gd); button_add.addSelectionListener(sel_adapter = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String id = ctx_text.getText(); if (id == null || id.length() == 0) return; Map<String, Object> props = new HashMap<String, Object>(); Image image = ImageCache.getImage(ImageCache.IMG_MEMORY_MAP); if (new MemoryMapItemDialog(map_table.getShell(), image, props, true).open() == Window.OK) { props.put(IMemoryMap.PROP_ID, id); ArrayList<IMemoryMap.MemoryRegion> lst = cur_maps.get(id); if (lst == null) cur_maps.put(id, lst = new ArrayList<IMemoryMap.MemoryRegion>()); lst.add(new TCFMemoryRegion(props)); table_viewer.refresh(); notifyModifyListeners(); } } }); final MenuItem item_add = new MenuItem(menu, SWT.PUSH); item_add.setText("&Add..."); //$NON-NLS-1$ item_add.addSelectionListener(sel_adapter); item_add.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ADD)); final Button button_edit = new Button(composite, SWT.PUSH); button_edit.setText(" E&dit... "); //$NON-NLS-1$ button_edit.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); button_edit.addSelectionListener(sel_adapter = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IMemoryMap.MemoryRegion r = (IMemoryMap.MemoryRegion) ((IStructuredSelection) table_viewer .getSelection()).getFirstElement(); if (r == null) return; editRegion(r); } }); final MenuItem item_edit = new MenuItem(menu, SWT.PUSH); item_edit.setText("E&dit..."); //$NON-NLS-1$ item_edit.addSelectionListener(sel_adapter); final Button button_remove = new Button(composite, SWT.PUSH); button_remove.setText(" &Remove "); //$NON-NLS-1$ button_remove.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); button_remove.addSelectionListener(sel_adapter = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String id = ctx_text.getText(); if (id == null || id.length() == 0) return; IMemoryMap.MemoryRegion r = (IMemoryMap.MemoryRegion) ((IStructuredSelection) table_viewer .getSelection()).getFirstElement(); if (r == null) return; ArrayList<IMemoryMap.MemoryRegion> lst = cur_maps.get(id); if (lst != null && lst.remove(r)) table_viewer.refresh(); notifyModifyListeners(); } }); final MenuItem item_remove = new MenuItem(menu, SWT.PUSH); item_remove.setText("&Remove"); //$NON-NLS-1$ item_remove.addSelectionListener(sel_adapter); item_remove.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ETOOL_DELETE)); final Button button_locate = new Button(composite, SWT.PUSH | SWT.WRAP); button_locate.setText(" Locate File... "); //$NON-NLS-1$ GridData layoutData = new GridData(GridData.FILL_HORIZONTAL); layoutData.widthHint = 50; button_locate.setLayoutData(layoutData); button_locate.addSelectionListener(sel_adapter = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String id = ctx_text.getText(); if (id == null || id.length() == 0) return; IMemoryMap.MemoryRegion r = (IMemoryMap.MemoryRegion) ((IStructuredSelection) table_viewer .getSelection()).getFirstElement(); if (r == null) return; locateSymbolFile(r); } }); new MenuItem(menu, SWT.SEPARATOR); final MenuItem item_locate = new MenuItem(menu, SWT.PUSH); item_locate.setText("Locate File..."); //$NON-NLS-1$ item_locate.addSelectionListener(sel_adapter); map_table.setMenu(menu); update_map_buttons = new Runnable() { public void run() { IMemoryMap.MemoryRegion r = (IMemoryMap.MemoryRegion) ((IStructuredSelection) table_viewer .getSelection()).getFirstElement(); boolean manual = r != null && r.getProperties().get(IMemoryMap.PROP_ID) != null; button_add.setEnabled(selected_mem_map_id != null); button_edit.setEnabled(r != null && !r.getProperties().containsKey(PROP_CHILDREN)); button_remove.setEnabled(manual); item_add.setEnabled(selected_mem_map_id != null); item_edit.setEnabled(r != null && !r.getProperties().containsKey(PROP_CHILDREN)); item_remove.setEnabled(manual); String symbolFileInfo = getSymbolFileInfo(r); boolean enabled = symbolFileInfo != null && symbolFileInfo.contains("Symbol file error:") //$NON-NLS-1$ && r.getFileName() != null; button_locate.setEnabled(enabled); item_locate.setEnabled(enabled); } }; update_map_buttons.run(); }
From source file:org.eclipse.tcf.internal.debug.ui.launch.TCFPathMapTab.java
License:Open Source License
private void createTableButtons(Composite parent) { Font font = parent.getFont(); Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 0;// w ww. ja va2 s .co m layout.marginWidth = 0; composite.setFont(font); composite.setLayout(layout); GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL); composite.setLayoutData(gd); Menu menu = new Menu(viewer.getTable()); SelectionAdapter sel_adapter = null; button_add = new Button(composite, SWT.PUSH); button_add.setText(" &Add... "); //$NON-NLS-1$ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); PixelConverter converter = new PixelConverter(button_add); gd.widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); button_add.setLayoutData(gd); button_add.addSelectionListener(sel_adapter = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { onAdd(); } }); item_add = new MenuItem(menu, SWT.PUSH); item_add.setText("&Add..."); //$NON-NLS-1$ item_add.addSelectionListener(sel_adapter); item_add.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ADD)); button_edit = new Button(composite, SWT.PUSH); button_edit.setText(" &Edit... "); //$NON-NLS-1$ button_edit.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); button_edit.addSelectionListener(sel_adapter = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { onEdit((IStructuredSelection) viewer.getSelection()); } }); item_edit = new MenuItem(menu, SWT.PUSH); item_edit.setText("&Edit..."); //$NON-NLS-1$ item_edit.addSelectionListener(sel_adapter); button_remove = new Button(composite, SWT.PUSH); button_remove.setText(" &Remove "); //$NON-NLS-1$ button_remove.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); button_remove.addSelectionListener(sel_adapter = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { onRemove((IStructuredSelection) viewer.getSelection()); } }); item_remove = new MenuItem(menu, SWT.PUSH); item_remove.setText("&Remove"); //$NON-NLS-1$ item_remove.addSelectionListener(sel_adapter); item_remove.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ETOOL_DELETE)); new MenuItem(menu, SWT.SEPARATOR); button_up = new Button(composite, SWT.PUSH); button_up.setText(" &Up "); //$NON-NLS-1$ button_up.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); button_up.addSelectionListener(sel_adapter = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { onUp(); } }); item_up = new MenuItem(menu, SWT.PUSH); item_up.setText("&Up"); //$NON-NLS-1$ item_up.addSelectionListener(sel_adapter); button_down = new Button(composite, SWT.PUSH); button_down.setText(" &Down "); //$NON-NLS-1$ button_down.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); button_down.addSelectionListener(sel_adapter = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { onDown(); } }); item_down = new MenuItem(menu, SWT.PUSH); item_down.setText("&Down"); //$NON-NLS-1$ item_down.addSelectionListener(sel_adapter); viewer.getTable().setMenu(menu); }
From source file:org.eclipse.tcf.te.ui.forms.parts.AbstractPartWithButtons.java
License:Open Source License
/** * Create the buttons panel./* ww w .ja v a2 s . c om*/ * * @param parent The parent composite. Must not be <code>null</code>. * @param toolkit The form toolkit or <code>null</code>. * * @return The buttons panel composite or <code>null</code>. */ protected Composite createButtonsPanel(Composite parent, FormToolkit toolkit) { if (labels == null || labels.size() == 0) { return null; } buttons = new Button[labels.size()]; Composite panel = createComposite(parent, toolkit); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; panel.setLayout(layout); GridData layoutData = new GridData(SWT.BEGINNING, SWT.FILL, false, true); panel.setLayoutData(layoutData); panel.setBackground(parent.getBackground()); SelectionListener listener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { AbstractPartWithButtons.this.onButtonSelected((Button) e.widget); } }; for (int i = 0; i < labels.size(); i++) { if (labels.get(i) != null) { Button button = toolkit != null ? toolkit.createButton(panel, null, SWT.PUSH) : new Button(panel, SWT.PUSH); Assert.isNotNull(button); button.setFont(JFaceResources.getDialogFont()); button.setText(labels.get(i)); button.setData(Integer.valueOf(i)); button.setBackground(panel.getBackground()); button.addSelectionListener(listener); onButtonCreated(button); layoutData = new GridData(SWT.FILL, SWT.BEGINNING, true, false); layoutData.widthHint = Math.max( new PixelConverter(button).convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH), button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); button.setLayoutData(layoutData); buttons[i] = button; } else { createEmptySpace(panel, 1, toolkit); } } return panel; }
From source file:org.eclipse.team.internal.ccvs.ui.CommentTemplatesPreferencePage.java
License:Open Source License
private void createButtons(Composite parent) { Composite buttons = new Composite(parent, SWT.NONE); buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); GridLayout layout = new GridLayout(); layout.marginHeight = 0;//from w ww . j av a2s .co m layout.marginWidth = 0; buttons.setLayout(layout); Button newButton = new Button(buttons, SWT.PUSH); newButton.setText(CVSUIMessages.CommentTemplatesPreferencePage_New); GridData data = new GridData(); data.horizontalAlignment = GridData.FILL; int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, newButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); newButton.setLayoutData(data); newButton.setEnabled(true); newButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { newTemplate(); } }); editButton = new Button(buttons, SWT.PUSH); editButton.setText(CVSUIMessages.CommentTemplatesPreferencePage_Edit); data = new GridData(); data.horizontalAlignment = GridData.FILL; widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, editButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); editButton.setLayoutData(data); editButton.setEnabled(false); editButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { editTemplate(); } }); removeButton = new Button(buttons, SWT.PUSH); removeButton.setText(CVSUIMessages.CommentTemplatesPreferencePage_Remove); data = new GridData(); data.horizontalAlignment = GridData.FILL; widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, removeButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); removeButton.setLayoutData(data); removeButton.setEnabled(false); removeButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { remove(); } }); }
From source file:org.eclipse.team.internal.ccvs.ui.CVSFolderPropertiesPage.java
License:Open Source License
/** * @see PreferencePage#createContents(Composite) *//* w w w. j a va2s . c o m*/ protected Control createContents(Composite parent) { initialize(); noDefaultAndApplyButton(); Composite composite = new Composite(parent, SWT.NULL); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); GridLayout layout = new GridLayout(); layout.numColumns = 2; composite.setLayout(layout); try { ICVSFolder cvsResource = CVSWorkspaceRoot.getCVSFolderFor(folder); if (!cvsResource.isManaged()) { if (cvsResource.isIgnored()) { createLabel(composite, CVSUIMessages.CVSFolderPropertiesPage_ignored, 2); } else { createLabel(composite, CVSUIMessages.CVSFolderPropertiesPage_notManaged, 2); } } else if (!cvsResource.isCVSFolder()) { // We have a managed folder which is not a cvs folder. // This is really an invalid state but it does happen once in a while createLabel(composite, CVSUIMessages.CVSFolderPropertiesPage_notCVSFolder, 2); } else { FolderSyncInfo syncInfo = cvsResource.getFolderSyncInfo(); createLabel(composite, CVSUIMessages.CVSFolderPropertiesPage_root); root = createReadOnlyText(composite, syncInfo.getRoot()); createLabel(composite, CVSUIMessages.CVSFolderPropertiesPage_repository); repository = createReadOnlyText(composite, syncInfo.getRepository()); // Tag createLabel(composite, CVSUIMessages.CVSFilePropertiesPage_tag); CVSTag tag = syncInfo.getTag(); if (tag != null && tag.getType() == CVSTag.BRANCH) { tag = Util.getAccurateFolderTag(folder, tag); } createReadOnlyText(composite, getTagLabel(tag)); // Static-ness if (syncInfo.getIsStatic()) { createLabel(composite, CVSUIMessages.CVSFolderPropertiesPage_static); createReadOnlyText(composite, syncInfo.getIsStatic() ? CVSUIMessages.yes : CVSUIMessages.no); // } createLabel(composite, "", 2); // spacer //$NON-NLS-1$ // Allow the folder to be disconnected from CVS control final Button disconnect = new Button(composite, SWT.NONE); disconnect.setText(CVSUIMessages.CVSFolderPropertiesPage_disconnect); GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END); int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, disconnect.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); disconnect.setLayoutData(data); disconnect.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { // perform a disconnect if (disconnectFolder()) { root.setText(CVSUIMessages.CVSFilePropertiesPage_none); repository.setText(CVSUIMessages.CVSFilePropertiesPage_none); disconnect.setEnabled(false); } } }); } } catch (TeamException e) { // Display error text createLabel(composite, CVSUIMessages.CVSFilePropertiesPage_error, 2); } PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.FOLDER_PROPERTY_PAGE); Dialog.applyDialogFont(parent); return composite; }
From source file:org.eclipse.team.internal.ccvs.ui.ExtMethodPreferencePage.java
License:Open Source License
protected Control createExternalArea(Composite parent) { Composite composite = new Composite(parent, SWT.NULL); GridLayout layout = new GridLayout(); layout.marginWidth = 5;//from w w w . j a v a 2 s . com layout.marginHeight = 5; layout.numColumns = 3; composite.setLayout(layout); composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Label intro = new Label(composite, SWT.LEFT | SWT.WRAP); intro.setText(CVSUIMessages.ExtMethodPreferencePage_message); GridData data = new GridData(); data.horizontalSpan = 3; data.horizontalAlignment = GridData.FILL; data.widthHint = 300; intro.setLayoutData(data); new Label(composite, SWT.LEFT).setText(CVSUIMessages.ExtMethodPreferencePage_CVS_RSH); cvsRsh = new Text(composite, SWT.BORDER); cvsRsh.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); final Button b = new Button(composite, SWT.NONE); b.setText(CVSUIMessages.ExtMethodPreferencePage_Browse); data = new GridData(); data.horizontalAlignment = GridData.FILL; int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, b.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); b.setLayoutData(data); b.addListener(SWT.MouseDown, new Listener() { public void handleEvent(Event event) { FileDialog d = new FileDialog(getShell()); d.setText(CVSUIMessages.ExtMethodPreferencePage_Details); String file = d.open(); if (file != null) { setCvsRshText(file); } } }); new Label(composite, SWT.LEFT).setText(CVSUIMessages.ExtMethodPreferencePage_CVS_RSH_Parameters); cvsRshParameters = new Text(composite, SWT.BORDER); data = new GridData(); data.horizontalSpan = 2; data.horizontalAlignment = GridData.FILL; cvsRshParameters.setLayoutData(data); new Label(composite, SWT.LEFT).setText(CVSUIMessages.ExtMethodPreferencePage_CVS_SERVER__7); cvsServer = new Text(composite, SWT.BORDER); data = new GridData(); data.horizontalSpan = 2; data.horizontalAlignment = GridData.FILL; cvsServer.setLayoutData(data); PlatformUI.getWorkbench().getHelpSystem().setHelp(cvsRsh, IHelpContextIds.EXT_PREFERENCE_RSH); PlatformUI.getWorkbench().getHelpSystem().setHelp(cvsRshParameters, IHelpContextIds.EXT_PREFERENCE_PARAM); PlatformUI.getWorkbench().getHelpSystem().setHelp(cvsServer, IHelpContextIds.EXT_PREFERENCE_SERVER); return composite; }
From source file:org.eclipse.team.internal.ui.mapping.FuzzFactorDialog.java
License:Open Source License
protected Control createDialogArea(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(2, 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); composite.setLayout(layout);//w w w .ja v a 2s . co m composite.setLayoutData(new GridData(GridData.FILL_BOTH)); applyDialogFont(composite); Label label = new Label(composite, SWT.WRAP); label.setText(TeamUIMessages.FuzzFactorDialog_message); GridData data = new GridData(); data.horizontalSpan = 2; label.setLayoutData(data); label.setFont(parent.getFont()); valueText = new Text(composite, SWT.SINGLE | SWT.BORDER); data = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); valueText.setLayoutData(data); valueText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { validateInput(); } }); fuzzFactor = patcher.getFuzz(); if (fuzzFactor >= 0) valueText.setText(new Integer(fuzzFactor).toString()); Button guessButton = new Button(composite, SWT.NONE); guessButton.setText(TeamUIMessages.FuzzFactorDialog_guess); data = new GridData(); int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); Point minSize = guessButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(widthHint, minSize.x); guessButton.setLayoutData(data); guessButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { patcher.setFuzz(-1); int fuzz = guessFuzzFactor(); if (fuzz >= 0) { String value = new Integer(fuzz).toString(); valueText.setText(value); } } }); errorMessageText = new Text(composite, SWT.READ_ONLY | SWT.WRAP); errorMessageText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); errorMessageText.setBackground(errorMessageText.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); validateInput(); applyDialogFont(composite); return composite; }
From source file:org.eclipse.team.internal.ui.wizards.ExportProjectSetLocationPage.java
License:Open Source License
private void createExportToFile(Composite composite) { fileRadio = new Button(composite, SWT.RADIO); fileRadio.setText(TeamUIMessages.ExportProjectSetMainPage_FileButton); fileRadio.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { saveToFileSystem = true;/*from www. j a v a 2 s . co m*/ file = fileCombo.getText(); updateEnablement(); } }); Composite inner = new Composite(composite, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2; layout.marginWidth = 0; inner.setLayout(layout); GridData data = new GridData(SWT.FILL, SWT.FILL, true, false); inner.setLayoutData(data); fileCombo = createDropDownCombo(inner); file = PsfFilenameStore.getInstance().getSuggestedDefault(); fileCombo.setItems(PsfFilenameStore.getInstance().getHistory()); fileCombo.setText(file); fileCombo.addListener(SWT.Modify, new Listener() { public void handleEvent(Event event) { file = fileCombo.getText(); updateEnablement(); } }); browseButton = new Button(inner, SWT.PUSH); browseButton.setText(TeamUIMessages.ExportProjectSetMainPage_Browse_4); data = new GridData(); data.horizontalAlignment = GridData.FILL; int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, browseButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); browseButton.setLayoutData(data); browseButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { if (!isSaveToFileSystem()) saveToFileSystem = true; FileDialog d = new FileDialog(getShell(), SWT.SAVE); d.setFilterExtensions(new String[] { "*.psf" }); //$NON-NLS-1$ d.setFilterNames(new String[] { TeamUIMessages.ExportProjectSetMainPage_Project_Set_Files_3 }); d.setFileName(TeamUIMessages.ExportProjectSetMainPage_default); String fileName = getFileName(); if (fileName != null) { int separator = fileName.lastIndexOf(System.getProperty("file.separator").charAt(0)); //$NON-NLS-1$ if (separator != -1) { fileName = fileName.substring(0, separator); } } d.setFilterPath(fileName); String f = d.open(); if (f != null) { fileCombo.setText(f); file = f; } } }); }
From source file:org.eclipse.team.internal.ui.wizards.ExportProjectSetLocationPage.java
License:Open Source License
private void createExportToWorkspace(Composite composite) { workspaceRadio = new Button(composite, SWT.RADIO); workspaceRadio.setText(TeamUIMessages.ExportProjectSetMainPage_WorkspaceButton); workspaceRadio.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { saveToFileSystem = false;//from w w w . jav a2s . co m updateEnablement(); } }); final Composite nameGroup = new Composite(composite, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2; layout.marginWidth = 0; nameGroup.setLayout(layout); final GridData data = new GridData(SWT.FILL, SWT.FILL, true, false); nameGroup.setLayoutData(data); workspaceText = createTextField(nameGroup); workspaceText.setEditable(false); workspaceText.addListener(SWT.Modify, new Listener() { public void handleEvent(Event event) { file = workspaceFile.getLocation().toString(); updateEnablement(); } }); Button wsBrowseButton = new Button(nameGroup, SWT.PUSH); GridData gd = new GridData(); gd.horizontalAlignment = GridData.FILL; int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); gd.widthHint = Math.max(widthHint, wsBrowseButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); wsBrowseButton.setLayoutData(gd); wsBrowseButton.setText(TeamUIMessages.ExportProjectSetMainPage_Browse); wsBrowseButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { if (isSaveToFileSystem()) saveToFileSystem = false; WorkspaceDialog d = new WorkspaceDialog(getShell()); d.open(); } }); }
From source file:org.eclipse.team.internal.ui.wizards.ImportProjectSetMainPage.java
License:Open Source License
public void createControl(Composite parent) { Composite composite = createComposite(parent, 1); initializeDialogUnits(composite);//w w w . j av a 2 s .c o m // set F1 help PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.IMPORT_PROJECT_SET_PAGE); Composite inner = new Composite(composite, SWT.NULL); inner.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); GridLayout layout = new GridLayout(); layout.numColumns = 3; layout.marginHeight = 0; layout.marginWidth = 0; inner.setLayout(layout); fileInputButton = new Button(inner, SWT.RADIO); fileInputButton.setText(TeamUIMessages.ImportProjectSetMainPage_Project_Set_File); fileInputButton.setEnabled(true); fileInputButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { setInputType(InputType_file); } }); fileCombo = createDropDownCombo(inner); file = psfFilenameStore.getSuggestedDefault(); fileCombo.setItems(psfFilenameStore.getHistory()); fileCombo.setText(file); fileCombo.addListener(SWT.Modify, new Listener() { public void handleEvent(Event event) { file = fileCombo.getText(); updateFileEnablement(); } }); browseButton = new Button(inner, SWT.PUSH); browseButton.setText(TeamUIMessages.ImportProjectSetMainPage_Browse_3); urlInputButton = new Button(inner, SWT.RADIO); urlInputButton.setText(TeamUIMessages.ImportProjectSetMainPage_Project_Set_Url); urlInputButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { setInputType(InputType_URL); } }); urlCombo = createDropDownCombo(inner); urlString = psfUrlStore.getSuggestedDefault(); urlCombo.setItems(psfUrlStore.getHistory()); urlCombo.setText(urlString); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; urlCombo.setLayoutData(gd); urlCombo.addListener(SWT.Modify, new Listener() { public void handleEvent(Event event) { urlString = urlCombo.getText(); updateUrlEnablement(); } }); GridData data = new GridData(); data.horizontalAlignment = GridData.FILL; int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, browseButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); browseButton.setLayoutData(data); browseButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { FileDialog d = new FileDialog(getShell()); d.setFilterExtensions(new String[] { "*.psf", "*" }); //$NON-NLS-1$ //$NON-NLS-2$ d.setFilterNames(new String[] { TeamUIMessages.ImportProjectSetMainPage_Project_Set_Files_2, TeamUIMessages.ImportProjectSetMainPage_allFiles }); // String fileName = getFileName(); if (fileName != null && fileName.length() > 0) { int separator = fileName.lastIndexOf(System.getProperty("file.separator").charAt(0)); //$NON-NLS-1$ if (separator != -1) { fileName = fileName.substring(0, separator); } } else { fileName = ResourcesPlugin.getWorkspace().getRoot().getLocation().toString(); } d.setFilterPath(fileName); String f = d.open(); if (f != null) { fileCombo.setText(f); file = f; } } }); addWorkingSetSection(composite); Button runInBackgroundCheckbox = SWTUtils.createCheckBox(composite, TeamUIMessages.ImportProjectSetMainPage_runInBackground, 3); runInBackgroundCheckbox.setSelection(isRunInBackgroundPreferenceOn()); runInBackgroundCheckbox.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { runInBackground = !runInBackground; } }); setControl(composite); setDefaultInputType(); Dialog.applyDialogFont(parent); }