List of usage examples for org.eclipse.jface.dialogs Dialog Dialog
protected Dialog(IShellProvider parentShell)
From source file:at.bestsolution.efxclipse.tooling.pde.e4.project.NewApplicationWizardPage.java
License:Open Source License
/** * create Rect Set dialog/* w w w . ja va 2 s. c o m*/ * * @param parent * @param valueText * @return */ public Dialog createRectDialog(final Composite parent, final Text valueText) { return new Dialog(parent.getShell()) { Text xPointText, yPointText, widthText, heightText; @Override protected Button createButton(Composite parent, int id, String label, boolean defaultButton) { return super.createButton(parent, id, label, defaultButton); } @Override protected Control createDialogArea(final Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); composite.getShell().setText("Set Rect"); Group group = new Group(composite, SWT.NONE); group.setText("Rect"); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 4; group.setLayout(gridLayout); Label xPointLabel = new Label(group, SWT.NONE); xPointLabel.setText("X:"); xPointText = new Text(group, SWT.BORDER); VerifyListener verifyListener = createVerifyListener(parent.getShell()); xPointText.addVerifyListener(verifyListener); Label yPointLabel = new Label(group, SWT.NONE); yPointLabel.setText("Y:"); yPointText = new Text(group, SWT.BORDER); yPointText.addVerifyListener(verifyListener); Label widthLabel = new Label(group, SWT.NONE); widthLabel.setText("Width:"); widthText = new Text(group, SWT.BORDER); widthText.addVerifyListener(verifyListener); Label heighttLabel = new Label(group, SWT.NONE); heighttLabel.setText("Height:"); heightText = new Text(group, SWT.BORDER); heightText.addVerifyListener(verifyListener); return composite; } @Override protected void buttonPressed(int buttonId) { if (IDialogConstants.OK_ID == buttonId) { String xPoint = xPointText.getText(); String yPoint = yPointText.getText(); String width = widthText.getText(); String height = heightText.getText(); if (xPoint.length() == 0 || yPoint.length() == 0 || width.length() == 0 || height.length() == 0) { MessageDialog.openWarning(parent.getShell(), "Input value empty", "Value shoud not be empty!"); } else { valueText.setText(xPoint + "," + yPoint + "," + width + "," + height); okPressed(); } } else if (IDialogConstants.CANCEL_ID == buttonId) { cancelPressed(); } } }; }
From source file:com.aptana.git.ui.internal.actions.AbstractGithubHandler.java
License:Open Source License
/** * Grabs the {@link IGithubRepository} for the selected repository. Forces user to login to github if not logged in. * If user cancels login or some other error occurs we bail out and return null. * /*from www . j av a 2 s. c o m*/ * @return * @throws ExecutionException */ protected IGithubRepository getGithubRepo() throws ExecutionException { final GitRepository repo = getSelectedRepository(); if (repo == null) { throw new ExecutionException(Messages.CreatePullRequestHandler_NoRepoErr); } IGithubRepository ghRepo = null; while (ghRepo == null) { try { ghRepo = repo.getGithubRepo(); } catch (CoreException ce) { if (ce.getStatus().getCode() == IGithubManager.GITHUB_LOGIN_CODE) { // prompt for login! final GithubAccountPageProvider userInfoProvider = new GithubAccountPageProvider(); Dialog dialog = new Dialog(UIUtils.getActiveShell()) { @Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); Control userInfoControl = userInfoProvider.createContents(composite); userInfoControl.setLayoutData( GridDataFactory.fillDefaults().grab(true, false).span(3, 1).create()); return composite; } @Override protected void okPressed() { if (!userInfoProvider.performOk()) { // TODO Show an error message that we were unable to login? return; } super.okPressed(); } }; if (dialog.open() == Window.CANCEL) { return null; // User cancelled } // we'll restart the loop and try again... } else { // some other error. Quit trying to get repo from github throw new ExecutionException(ce.getMessage(), ce); } } } return ghRepo; }
From source file:com.cloudbees.eclipse.dtp.internal.actions.ShowPasswordAction.java
License:Open Source License
@Override public void run(IAction action) { if (action instanceof ObjectPluginAction) { ObjectPluginAction pluginAction = (ObjectPluginAction) action; ISelection selection = pluginAction.getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection structSelection = (IStructuredSelection) selection; Object element = structSelection.getFirstElement(); if (element instanceof DatabaseInfo) { DatabaseInfo db = (DatabaseInfo) element; try { final DatabaseInfo dbi = BeesSDK.getDatabaseInfo(db.getName(), true); final String psw = dbi.getPassword(); Dialog pswd = new Dialog(Display.getCurrent().getActiveShell()) { @Override protected void configureShell(Shell newShell) { super.configureShell(newShell); newShell.setText("Password for database '" + dbi.getName() + "'"); }/* w w w . ja v a 2 s . c om*/ protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); } @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); GridLayout layout = new GridLayout(); layout.numColumns = 2; container.setLayout(layout); GridData gridData = new GridData(); gridData.grabExcessHorizontalSpace = true; gridData.horizontalAlignment = GridData.FILL; Label dbLabel = new Label(container, SWT.NONE); dbLabel.setText("Database: "); Text dbNameText = new Text(container, SWT.BORDER); dbNameText.setText(dbi.getName()); dbNameText.setLayoutData(gridData); dbNameText.setEditable(false); dbNameText.setEnabled(true); Label pswLabel = new Label(container, SWT.NONE); pswLabel.setText("Password: "); gridData = new GridData(); gridData.grabExcessHorizontalSpace = true; gridData.horizontalAlignment = GridData.FILL; Text pswText = new Text(container, SWT.BORDER); pswText.setText(psw); pswText.setEditable(false); pswText.setEnabled(true); pswText.setLayoutData(gridData); pswText.setFocus(); pswText.selectAll(); return container; } }; pswd.create(); pswd.open(); //MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Password for database '"+dbi.getName()+"'", "Database: "+dbi.getName()+"\nPassword: "+dbi.getPassword()); } catch (Exception e) { CloudBeesUIPlugin.showError("Failed to fetch database password!", e); } } } } }
From source file:com.nokia.testfw.test.framework.ControlTestCase.java
License:Open Source License
/** * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. */// w w w . j ava2 s. co m protected void setUp() throws Exception { Shell shell = Display.getDefault().getActiveShell(); dialog = new Dialog(shell) { Control testComposite; protected Control createDialogArea(Composite parent) { testComposite = createTestControl(parent); String title = "Test:"; if (testComposite != null) { String clsName = testComposite.getClass().getName(); int index = clsName.lastIndexOf("."); if (index > 0) { clsName = clsName.substring(index + 1); } title = title + clsName; } parent.getShell().setText(title); return testComposite; } }; dialog.setBlockOnOpen(false); dialog.open(); //delay for 2 seconds after dialog open TestUtils.delay(2000); }
From source file:com.nokia.tools.variant.editor.actions.HideSettingsFromViewAction.java
License:Open Source License
private boolean dialogOK() { Dialog d = new Dialog(Display.getCurrent().getActiveShell()) { protected Control createDialogArea(Composite parent) { Composite control = new Composite(parent, SWT.NONE); control.setLayout(new GridLayout()); Label label = new Label(control, SWT.NONE); label.setText("Remove settings from:"); Button allGroupsButton = new Button(control, SWT.RADIO); allGroupsButton.setText("All groups"); allGroupsButton.setSelection(true); allGroupsButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { removeFromAllGroups = true; }/*from www . ja v a 2 s. c o m*/ }); Button selectedGroupButton = new Button(control, SWT.RADIO); selectedGroupButton.setText("Selected group"); selectedGroupButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { removeFromAllGroups = false; } }); return super.createDialogArea(parent); } @Override protected void configureShell(Shell newShell) { super.configureShell(newShell); newShell.setText("Multiple references for a setting found"); } @Override protected Point getInitialSize() { return new Point(350, 150); } }; if (d.open() == Dialog.OK) { return true; } return false; }
From source file:com.symbian.smt.gui.smtwidgets.ModelControlWidgetTest.java
License:Open Source License
protected void setUp() throws Exception { // Initialise the default values SmmPreferencesInitializer initialiser = new SmmPreferencesInitializer(); initialiser.initializeDefaultPreferences(); IWorkbench workbench = PlatformUI.getWorkbench(); Shell shell = workbench.getActiveWorkbenchWindow().getShell(); dialog = new Dialog(shell) { protected Control createContents(Composite parent) { Composite c = new Composite(parent, SWT.NONE); c.setLayout(new FillLayout()); modelControlWidget = new ModelControlWidget(c, SWT.NONE); return c; }/*from w ww .j a va2 s . co m*/ }; dialog.setBlockOnOpen(false); dialog.open(); }
From source file:de.jaret.util.ui.table.util.action.ConfigureColumnsAction.java
License:Open Source License
/** * {@inheritDoc}//from w w w .j ava2s . c om */ public void run() { save(); Dialog confColsDialog = new Dialog(Display.getCurrent().getActiveShell()) { @Override protected Control createDialogArea(Composite parent) { return createColumnControlPanel(parent); } }; int result = confColsDialog.open(); if (result == Dialog.CANCEL) { restore(); } }
From source file:eu.hydrologis.jgrass.formeditor.model.widgets.FormComboCellEditor.java
License:Open Source License
private void handleEvent() { Shell shell = new Shell(Display.getDefault(), SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL); Dialog dialog = new Dialog(shell) { @Override//from ww w. j a va 2 s. co m protected void configureShell(Shell shell) { super.configureShell(shell); shell.setText("Insert data"); } @Override protected Point getInitialSize() { return new Point(320, 300); } @Override protected Control createDialogArea(Composite parent) { Composite mainComposite = new Composite(parent, SWT.NONE); mainComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); mainComposite.setLayout(new GridLayout(2, false)); manualButton = new Button(mainComposite, SWT.RADIO); manualButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); manualButton.setText("Manual"); manualButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { boolean selection = manualButton.getSelection(); handleEnablements(selection); } }); manualText = new Text(mainComposite, SWT.SINGLE | SWT.LEAD | SWT.BORDER); manualText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); manualText.setText(""); fileButton = new Button(mainComposite, SWT.RADIO); GridData fileButtonGD = new GridData(SWT.BEGINNING, SWT.CENTER, false, false); fileButtonGD.horizontalSpan = 2; fileButton.setLayoutData(fileButtonGD); fileButton.setText("File"); fileButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { boolean selection = fileButton.getSelection(); handleEnablements(!selection); } }); Group fileGroup = new Group(mainComposite, SWT.NONE); GridData fileGroupGD = new GridData(SWT.FILL, SWT.FILL, true, false); fileGroupGD.horizontalSpan = 2; fileGroup.setLayoutData(fileGroupGD); fileGroup.setLayout(new GridLayout(3, false)); // fileGroup.setText(); Label pathLabel = new Label(fileGroup, SWT.NONE); pathLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); pathLabel.setText("Path"); pathText = new Text(fileGroup, SWT.SINGLE | SWT.LEAD | SWT.BORDER | SWT.READ_ONLY); pathText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); pathText.setText(""); browseButton = new Button(fileGroup, SWT.PUSH); browseButton.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); browseButton.setText("..."); //$NON-NLS-1$ browseButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { IMap activeMap = ApplicationGIS.getActiveMap(); ILayer selectedLayer = activeMap.getEditManager().getSelectedLayer(); ID id = selectedLayer.getGeoResource().getID(); if (id.isFile()) { File layerFile = id.toFile(); FileDialog fileDialog = new FileDialog(pathText.getShell(), SWT.OPEN); // fileDialog.setFilterExtensions(extentions); fileDialog.setFilterPath(layerFile.getParent()); String path = fileDialog.open(); if (path != null && path.length() >= 1) { File tableFile = new File(path); String tableParentName = tableFile.getParentFile().getName().trim(); String layerParentName = layerFile.getParentFile().getName().trim(); if (tableParentName.equals(layerParentName)) { pathText.setText(tableFile.getName()); } else { MessageDialog.openWarning(browseButton.getShell(), "WARNING", "The linked table needs to be inside of the same folder as the resource file."); } } } else { MessageDialog.openWarning(browseButton.getShell(), "WARNING", "Currently linking of files is supported only for file based resources."); handleEnablements(true); } } }); Label separatorBabel = new Label(fileGroup, SWT.NONE); separatorBabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); separatorBabel.setText("Separator"); separatorText = new Text(fileGroup, SWT.SINGLE | SWT.LEAD | SWT.BORDER); GridData separatorTextGD = new GridData(SWT.FILL, SWT.CENTER, true, false); separatorTextGD.horizontalSpan = 2; separatorText.setLayoutData(separatorTextGD); separatorText.setText(","); linkButton = new Button(fileGroup, SWT.CHECK); GridData linkButtonGD = new GridData(SWT.BEGINNING, SWT.CENTER, false, false); linkButtonGD.horizontalSpan = 3; linkButton.setLayoutData(linkButtonGD); linkButton.setText("link file"); Label attributeValueLabel = new Label(fileGroup, SWT.NONE); attributeValueLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); attributeValueLabel.setText("Attribute value column"); attributeValueText = new Text(fileGroup, SWT.SINGLE | SWT.LEAD | SWT.BORDER); GridData attributeValueGD = new GridData(SWT.FILL, SWT.CENTER, true, false); attributeValueGD.horizontalSpan = 2; attributeValueText.setLayoutData(attributeValueGD); attributeValueText.setText("1"); Label guiNameLabel = new Label(fileGroup, SWT.NONE); guiNameLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); guiNameLabel.setText("Interface name column"); guiNameText = new Text(fileGroup, SWT.SINGLE | SWT.LEAD | SWT.BORDER); GridData guiNameTextGD = new GridData(SWT.FILL, SWT.CENTER, true, false); guiNameTextGD.horizontalSpan = 2; guiNameText.setLayoutData(guiNameTextGD); guiNameText.setText("2"); setValuesFromValueString(); return mainComposite; } @Override protected void buttonPressed(int buttonId) { if (buttonId == OK) { if (manualButton.getSelection()) { valueString = manualText.getText(); } else { setValueStringFromFileType(); } editOccured(null); } super.buttonPressed(buttonId); } }; dialog.setBlockOnOpen(true); dialog.open(); // Point location = mainButton.getLocation(); // // Point size = dialog.getSize(); // dialog.setLocation(location.x - size.x, location.y + size.y); }
From source file:eu.hydrologis.jgrass.ui.actions.g_setmapset.java
License:Open Source License
public void run(IAction action) { final ScopedPreferenceStore m_preferences = (ScopedPreferenceStore) ConsoleEditorPlugin.getDefault() .getPreferenceStore();//from w w w . java2 s.c om Dialog dialog = new Dialog(window.getShell()) { private Text text; protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); composite.setLayout(new GridLayout(4, false)); Label label = new Label(composite, SWT.NONE); label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); label.setText("mapset path"); mapset = m_preferences.getString(PreferencesInitializer.CONSOLE_ARGV_MAPSET); if (mapset != null) { File f = new File(mapset); if (!f.exists()) { mapset = ""; } } text = new Text(composite, SWT.SINGLE | SWT.LEAD | SWT.BORDER); text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); text.setText(mapset); final Button mapsetSelectionButton = new Button(composite, SWT.PUSH); mapsetSelectionButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); mapsetSelectionButton.setToolTipText("Select a mapset from the catalog."); mapsetSelectionButton.setText("catalog"); mapsetSelectionButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { CatalogJGrassMapsetTreeViewerDialog cDialog = new CatalogJGrassMapsetTreeViewerDialog(); cDialog.open(mapsetSelectionButton.getShell()); List<JGrassMapsetGeoResource> selectedLayers = cDialog.getSelectedLayers(); if (selectedLayers == null || selectedLayers.size() == 0) { return; } JGrassMapsetGeoResource grassMapsetGeoResource = selectedLayers.get(0); File mapsetFile = grassMapsetGeoResource.getFile(); if (mapsetFile.exists() && GrassPlugin.getDefault().isMapsetConsistent(mapsetFile.getAbsolutePath())) { text.setText(mapsetFile.getAbsolutePath()); } else { String msg = "This is not a valid GRASS mapset folder. Please supply a valid mapset folder."; popupError(msg); } } }); Button browseButton = new Button(composite, SWT.PUSH); browseButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); browseButton.setText("..."); browseButton.setToolTipText("Browse the filesystem for a mapset folder."); browseButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { DirectoryDialog fileDialog = new DirectoryDialog(window.getShell(), SWT.OPEN); String path = fileDialog.open(); if (path != null) { File f = new File(path); if (f.exists() && GrassPlugin.getDefault().isMapsetConsistent(path)) { text.setText(f.getAbsolutePath()); } else { String msg = "This is not a valid GRASS mapset folder. Please supply a valid mapset folder."; popupError(msg); } } } }); return composite; } protected void configureShell(Shell shell) { super.configureShell(shell); shell.setText("g.setmapset"); shell.setSize(new Point(450, 120)); Shell mainshell = PlatformUI.getWorkbench().getDisplay().getActiveShell(); Rectangle bounds = mainshell.getBounds(); Rectangle rect = shell.getBounds(); int x = bounds.x + (bounds.width - rect.width) / 2; int y = bounds.y + (bounds.height - rect.height) / 2; shell.setLocation(x, y); } protected void okPressed() { m_preferences.setValue(PreferencesInitializer.CONSOLE_ARGV_MAPSET, text.getText()); super.okPressed(); } }; dialog.setBlockOnOpen(true); dialog.open(); }
From source file:eu.hydrologis.jgrass.ui.utilities.CatalogJGrassMapsetTreeViewerDialog.java
License:Open Source License
public void open(Shell parentShell) { try {// ww w. j a v a2 s. com setRequireContinue(false); Dialog dialog = new Dialog(parentShell) { @Override protected void configureShell(Shell shell) { super.configureShell(shell); shell.setText(Messages.getString("CatalogJGrassMapsetTreeViewerDialog.choosemapset")); //$NON-NLS-1$ } @Override protected Point getInitialSize() { return new Point(250, 250); } @Override protected Control createDialogArea(Composite parent) { Composite parentPanel = (Composite) super.createDialogArea(parent); GridLayout gLayout = (GridLayout) parentPanel.getLayout(); gLayout.numColumns = 1; active = new CatalogJGrassMapsetsTreeViewer(parentPanel, SWT.BORDER, SWT.SINGLE); return parentPanel; } @Override protected void buttonPressed(int buttonId) { super.buttonPressed(buttonId); if (buttonId == OK) { newLayers = active.getSelectedLayers(); } else { newLayers = null; } setRequireContinue(true); } }; dialog.setBlockOnOpen(true); dialog.open(); while (!isContinueRequired()) { if (dialog.getShell().isDisposed()) { break; } if (Display.getCurrent().readAndDispatch()) { continue; } try { Thread.sleep(300); } catch (InterruptedException ex) { ex.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); } }