List of usage examples for org.eclipse.jface.dialogs Dialog open
public int open()
From source file:org.eclipse.ptp.internal.remote.terminal.RemoteConnection.java
License:Open Source License
/** * The param "str" should be a list of files delimited by "~~". The * user will be shown a choice dialog, allowing the user to pick one * file to open. This selects one file from a list obtained by a shell * wild card./*w w w. ja v a 2 s . c o m*/ * * @param str */ private void doChoiceAction(final String str) { final String[] choices = str.split("\\s*~~\\s*"); //$NON-NLS-1$ getStandardDisplay().asyncExec(new Runnable() { @Override public void run() { try { final Dialog dialog = new Dialog(getStandardDisplay().getActiveShell()) { Combo combo; String[] comboChoices; @Override protected void configureShell(Shell shell) { shell.setText(Messages.CHOOSE_FILE); super.configureShell(shell); } @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); combo = new Combo(container, SWT.NONE); combo.setItems(choices); comboChoices = choices; Point pt = combo.computeSize(SWT.DEFAULT, SWT.DEFAULT); combo.setSize(pt.x, 5 * pt.y); return container; } @Override public void buttonPressed(int buttonId) { int n = combo.getSelectionIndex(); if (buttonId == 0 && n >= 0 && n < comboChoices.length) { openFile(comboChoices[n]); } close(); } }; dialog.open(); } catch (Exception t) { Activator.log(t); } } }); }
From source file:org.eclipse.ptp.internal.remote.terminal.RemoteConnection.java
License:Open Source License
/** * Creates a dialog with a radio button that will perform one shell command * from a list. The string ~~ is used to delimit commands, and ::~ is used * to separate user-displayed text from the command itself. Thus, a script * containing://from w w w .j a v a2 s . c om * * <pre> * #!/bin/bash * echo "~~EPTP:Radio~~ List Files::~ls -F~~Current Dir::~pwd" * </pre> * * Will produce a menu allowing the user to select from "List Files" and * "Current Dir". The former will perform an "ls -F", the latter will * perform a "pwd" command. * * @param str */ private void doRadioAction(final String str) { final String[] choices = str.split("\\s*~~\\s*"); //$NON-NLS-1$ getStandardDisplay().asyncExec(new Runnable() { @Override public void run() { try { final Dialog dialog = new Dialog(getStandardDisplay().getActiveShell()) { private final Map<String, String> smap = new HashMap<String, String>(); private final List<Button> buttons = new ArrayList<Button>(); @Override protected void configureShell(Shell shell) { shell.setText(Messages.CHOOSE_FILE); super.configureShell(shell); } @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); for (String choice : choices) { String[] keyvalue = choice.split("::~"); //$NON-NLS-1$ if (keyvalue.length == 2) { Button b = new Button(container, SWT.RADIO); b.setText(keyvalue[0]); smap.put(keyvalue[0], keyvalue[1]); buttons.add(b); } } return container; } @Override public void buttonPressed(int buttonId) { if (buttonId == 0) { for (Button b : buttons) { if (b.getSelection()) { String value = smap.get(b.getText()); try { OutputStream out = fProcess.getOutputStream(); out.write((value + "\n").getBytes()); //$NON-NLS-1$ out.flush(); } catch (IOException ioe) { } } } } close(); } }; dialog.open(); } catch (Exception t) { Activator.log(t); } } }); }
From source file:org.eclipse.ptp.internal.remote.terminal.RemoteTerminalParser.java
License:Open Source License
/** * The param "str" should be a list of files delimited by "~~". The * user will be shown a choice dialog, allowing the user to pick one * file to open. This selects one file from a list obtained by a shell * wild card.// w ww .ja v a 2s . co m * * @param str */ private void doChoiceAction(final String str, final String arg) { final String[] choices = str.split("\\s*~~\\s*"); //$NON-NLS-1$ getStandardDisplay().asyncExec(new Runnable() { @Override public void run() { try { final Dialog dialog = new Dialog(getStandardDisplay().getActiveShell()) { private Combo combo; private String[] comboChoices; @Override public void buttonPressed(int buttonId) { int n = combo.getSelectionIndex(); if (buttonId == 0 && n >= 0 && n < comboChoices.length) { openFile(comboChoices[n], arg); } close(); } @Override protected void configureShell(Shell shell) { shell.setText(Messages.CHOOSE_FILE); super.configureShell(shell); } @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); combo = new Combo(container, SWT.NONE); combo.setItems(choices); comboChoices = choices; Point pt = combo.computeSize(SWT.DEFAULT, SWT.DEFAULT); combo.setSize(pt.x, 5 * pt.y); return container; } }; dialog.open(); } catch (Exception t) { Activator.log(t); } } }); }
From source file:org.eclipse.ptp.internal.remote.terminal.RemoteTerminalParser.java
License:Open Source License
/** * Creates a dialog with a radio button that will perform one shell command * from a list. The string ~~ is used to delimit commands, and ::~ is used * to separate user-displayed text from the command itself. Thus, a script * containing://w w w . ja v a2s. co m * * <pre> * #!/bin/bash * echo "~~EPTP:Radio~~ List Files::~ls -F~~Current Dir::~pwd" * </pre> * * Will produce a menu allowing the user to select from "List Files" and * "Current Dir". The former will perform an "ls -F", the latter will * perform a "pwd" command. * * @param str */ private void doRadioAction(final String str) { final String[] choices = str.split("\\s*~~\\s*"); //$NON-NLS-1$ getStandardDisplay().asyncExec(new Runnable() { @Override public void run() { try { final Dialog dialog = new Dialog(getStandardDisplay().getActiveShell()) { private final Map<String, String> smap = new HashMap<String, String>(); private final List<Button> buttons = new ArrayList<Button>(); @Override public void buttonPressed(int buttonId) { if (buttonId == 0) { for (Button b : buttons) { if (b.getSelection()) { String value = smap.get(b.getText()); try { OutputStream out = fProcess.getOutputStream(); out.write((value + "\n").getBytes()); //$NON-NLS-1$ out.flush(); } catch (IOException ioe) { } } } } close(); } @Override protected void configureShell(Shell shell) { shell.setText(Messages.CHOOSE_FILE); super.configureShell(shell); } @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); for (String choice : choices) { String[] keyvalue = choice.split("::~"); //$NON-NLS-1$ if (keyvalue.length == 2) { Button b = new Button(container, SWT.RADIO); b.setText(keyvalue[0]); smap.put(keyvalue[0], keyvalue[1]); buttons.add(b); } } return container; } }; dialog.open(); } catch (Exception t) { Activator.log(t); } } }); }
From source file:org.eclipse.ptp.launch.ui.EnhancedSynchronizeTab.java
License:Open Source License
protected void handleEditRuleButtonPressed() { if (ruleList.getSelectionCount() != 1) return;/*from ww w . ja va2 s . co m*/ int index = ruleList.getSelectionIndex(); ISynchronizationRule rule = rules.get(index); Dialog dialog = RuleDialogFactory.createDialogForRule(getShell(), rule); if (dialog != null) { if (dialog.open() == Dialog.OK) { IRuleDialog ruleDialog = (IRuleDialog) dialog; ISynchronizationRule newRule = RuleFactory.duplicateRule(ruleDialog.getRuleWorkingCopy()); rules.set(index, newRule); } } else { MessageDialog.openError(getShell(), Messages.EnhancedSynchronizeTab_ErrorMessage_NewRule_Title, Messages.EnhancedSynchronizeTab_ErrorMessage_NewRule_DontKnowRuleType); } refreshRuleList(); dataChanged = true; updateLaunchConfigurationDialog(); }
From source file:org.eclipse.ptp.launch.ui.EnhancedSynchronizeTab.java
License:Open Source License
/** * @since 5.0/* w ww .j a v a2 s . c om*/ */ protected void newRuleDialog(ISynchronizationRule rule) { Dialog dialog = RuleDialogFactory.createDialogForRule(getShell(), rule); if (dialog != null) { if (dialog.open() == Dialog.OK) { IRuleDialog ruleDialog = (IRuleDialog) dialog; ISynchronizationRule newRule = RuleFactory.duplicateRule(ruleDialog.getRuleWorkingCopy()); rules.add(newRule); } } else { MessageDialog.openError(getShell(), Messages.EnhancedSynchronizeTab_ErrorMessage_NewRule_Title, Messages.EnhancedSynchronizeTab_ErrorMessage_NewRule_DontKnowRuleType); } refreshRuleList(); dataChanged = true; updateLaunchConfigurationDialog(); }
From source file:org.eclipse.ptp.launch.ui.tabs.EnhancedSynchronizeTab.java
License:Open Source License
protected void handleEditRuleButtonPressed() { if (ruleList.getSelectionCount() != 1) { return;// w w w. j a v a2 s .c o m } int index = ruleList.getSelectionIndex(); ISynchronizationRule rule = rules.get(index); Dialog dialog = RuleDialogFactory.createDialogForRule(getShell(), rule); if (dialog != null) { if (dialog.open() == Dialog.OK) { IRuleDialog ruleDialog = (IRuleDialog) dialog; ISynchronizationRule newRule = RuleFactory.duplicateRule(ruleDialog.getRuleWorkingCopy()); rules.set(index, newRule); } } else { MessageDialog.openError(getShell(), Messages.EnhancedSynchronizeTab_ErrorMessage_NewRule_Title, Messages.EnhancedSynchronizeTab_ErrorMessage_NewRule_DontKnowRuleType); } refreshRuleList(); dataChanged = true; updateLaunchConfigurationDialog(); }
From source file:org.eclipse.ptp.remotetools.environment.launcher.ui.EnhancedSynchronizeTab.java
License:Open Source License
protected void newRuleDialog(ISynchronizationRule rule) { Dialog dialog = RuleDialogFactory.createDialogForRule(getShell(), rule); if (dialog != null) { if (dialog.open() == Dialog.OK) { IRuleDialog ruleDialog = (IRuleDialog) dialog; ISynchronizationRule newRule = RuleFactory.duplicateRule(ruleDialog.getRuleWorkingCopy()); rules.add(newRule);//from w w w. j a va2 s .co m } } else { MessageDialog.openError(getShell(), Messages.EnhancedSynchronizeTab_ErrorMessage_NewRule_Title, Messages.EnhancedSynchronizeTab_ErrorMessage_NewRule_DontKnowRuleType); } refreshRuleList(); dataChanged = true; updateLaunchConfigurationDialog(); }
From source file:org.eclipse.ptp.remotetools.environment.launcher.ui.EnhancedSynchronizeTab.java
License:Open Source License
protected void handleEditRuleButtonPressed() { if (ruleList.getSelectionCount() != 1) return;/*from w w w.j a v a 2 s . c o m*/ int index = ruleList.getSelectionIndex(); ISynchronizationRule rule = (ISynchronizationRule) rules.get(index); Dialog dialog = RuleDialogFactory.createDialogForRule(getShell(), rule); if (dialog != null) { if (dialog.open() == Dialog.OK) { IRuleDialog ruleDialog = (IRuleDialog) dialog; ISynchronizationRule newRule = RuleFactory.duplicateRule(ruleDialog.getRuleWorkingCopy()); rules.set(index, newRule); } } else { MessageDialog.openError(getShell(), Messages.EnhancedSynchronizeTab_ErrorMessage_NewRule_Title, Messages.EnhancedSynchronizeTab_ErrorMessage_NewRule_DontKnowRuleType); } refreshRuleList(); dataChanged = true; updateLaunchConfigurationDialog(); }
From source file:org.eclipse.rcptt.ui.launching.ExecutionView.java
License:Open Source License
private void createFailTrace(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginWidth = 0;//from w w w .ja v a 2 s. c o m layout.marginHeight = 0; composite.setLayout(layout); Composite detailsHeader = new Composite(composite, SWT.NONE); GridLayout detailsHeaderLayout = new GridLayout(2, false); detailsHeaderLayout.marginWidth = 5; detailsHeaderLayout.marginHeight = 0; detailsHeader.setLayout(detailsHeaderLayout); detailsHeader.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); Label label = new Label(detailsHeader, SWT.LEFT); label.setText(DETAILS_LABEL); advInfoButton = new Button(detailsHeader, SWT.PUSH); advInfoButton.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END)); advInfoButton.setText(ADVANCED_INFO_LABEL); advInfoButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Dialog dialog = new DetailsDialog(failureTrace.getShell(), report); dialog.open(); } }); advInfoButton.setEnabled(false); failureTrace = new StyledText(composite, SWT.BORDER | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL | SWT.WRAP); failureTrace.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); }