Search in sources :

Example 76 with FileDialog

use of org.eclipse.swt.widgets.FileDialog in project linuxtools by eclipse.

the class OprofileSetupTab method showFileDialog.

// Displays a file dialog to allow the user to select the kernel image file
private void showFileDialog(Shell shell) {
    try {
        proxy = RemoteProxyManager.getInstance().getFileProxy(getOprofileProject());
    } catch (CoreException e) {
        e.printStackTrace();
    }
    FileDialog d = new FileDialog(shell, SWT.OPEN);
    IFileStore kernel = proxy.getResource(options.getKernelImageFile());
    if (!kernel.fetchInfo().exists()) {
        // $NON-NLS-1$
        kernel = proxy.getResource("/boot");
        if (!kernel.fetchInfo().exists()) {
            // $NON-NLS-1$
            kernel = proxy.getResource("/");
        }
    }
    d.setFileName(kernel.toString());
    // $NON-NLS-1$
    d.setText(OprofileLaunchMessages.getString("tab.global.selectKernelDialog.text"));
    String newKernel = d.open();
    if (newKernel != null) {
        kernel = proxy.getResource(newKernel);
        if (!kernel.fetchInfo().exists()) {
            MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.RETRY | SWT.CANCEL);
            // $NON-NLS-1$
            mb.setMessage(OprofileLaunchMessages.getString("tab.global.selectKernelDialog.error.kernelDoesNotExist.text"));
            switch(mb.open()) {
                case SWT.RETRY:
                    // Ok, it's recursive, but it shouldn't matter
                    showFileDialog(shell);
                    break;
                default:
                case SWT.CANCEL:
                    break;
            }
        } else {
            kernelImageFileText.setText(newKernel);
        }
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IFileStore(org.eclipse.core.filesystem.IFileStore) FileDialog(org.eclipse.swt.widgets.FileDialog) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 77 with FileDialog

use of org.eclipse.swt.widgets.FileDialog in project linuxtools by eclipse.

the class LocalResourceSelectorProxy method selectFile.

@Override
public URI selectFile(String scheme, String initialPath, String prompt, Shell shell) {
    FileDialog dialog = new FileDialog(shell, SWT.SHEET);
    dialog.setText(prompt);
    dialog.setFilterPath(initialPath);
    try {
        String path = dialog.open();
        if (path != null)
            return new URI(path);
        else
            return null;
    } catch (URISyntaxException e) {
        return null;
    }
}
Also used : URISyntaxException(java.net.URISyntaxException) FileDialog(org.eclipse.swt.widgets.FileDialog) URI(java.net.URI)

Example 78 with FileDialog

use of org.eclipse.swt.widgets.FileDialog in project linuxtools by eclipse.

the class SystemTapScriptOptionsTab method createControl.

@Override
public void createControl(Composite parent) {
    GridLayout singleColumnGridLayout = new GridLayout();
    singleColumnGridLayout.numColumns = 1;
    Composite comp = new Composite(parent, SWT.NONE);
    setControl(comp);
    comp.setLayout(singleColumnGridLayout);
    comp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    this.fileDialog = new FileDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.OPEN);
    fileDialog.setText(Messages.SystemTapScriptOptionsTab_selectExec);
    fileDialog.setFilterPath(Platform.getLocation().toOSString());
    // Target Executable path
    Group targetExecutableGroup = new Group(comp, SWT.SHADOW_ETCHED_IN);
    targetExecutableGroup.setText(Messages.SystemTapScriptOptionsTab_targetExec);
    targetExecutableGroup.setToolTipText(Messages.SystemTapScriptOptionsTab_targetToolTip);
    targetExecutableGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    GridLayout twoColumnGridLayout = new GridLayout();
    twoColumnGridLayout.numColumns = 2;
    targetExecutableGroup.setLayout(twoColumnGridLayout);
    this.targetProgramText = new Text(targetExecutableGroup, SWT.SINGLE | SWT.BORDER);
    targetProgramText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    targetProgramText.addModifyListener(modifyListener);
    Button selectTargetProgramButton = new Button(targetExecutableGroup, 0);
    GridData gridData = new GridData();
    selectTargetProgramButton.setLayoutData(gridData);
    selectTargetProgramButton.setText(Messages.SystemTapScriptLaunchConfigurationTab_browse);
    selectTargetProgramButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
        String fileName = fileDialog.open();
        if (fileName != null) {
            targetProgramText.setText(fileName);
        }
    }));
    // Check boxes
    Composite cmpChkBoxes = new Composite(comp, SWT.NONE);
    cmpChkBoxes.setLayout(twoColumnGridLayout);
    cmpChkBoxes.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
    for (int i = 0; i < IDEPreferenceConstants.STAP_BOOLEAN_OPTIONS.length; i++) {
        checkBox[i] = new Button(cmpChkBoxes, SWT.CHECK);
        checkBox[i].setText(IDEPreferenceConstants.STAP_BOOLEAN_OPTIONS[i][IDEPreferenceConstants.LABEL] + " (" + IDEPreferenceConstants.STAP_BOOLEAN_OPTIONS[i][IDEPreferenceConstants.FLAG] + // $NON-NLS-1$//$NON-NLS-2$
        ")");
        checkBox[i].addSelectionListener(new SelectionListener() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                updateLaunchConfigurationDialog();
            }

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
                updateLaunchConfigurationDialog();
            }
        });
        checkBox[i].setToolTipText(IDEPreferenceConstants.STAP_BOOLEAN_OPTIONS[i][IDEPreferenceConstants.TOOLTIP]);
        if (IDEPreferenceConstants.STAP_BOOLEAN_OPTIONS[i][IDEPreferenceConstants.FLAG].contains(Messages.SystemTapScriptOptionsTab_dyninst)) {
            this.dyninstCheckBox = checkBox[i];
        }
    }
    // Labels and Text fields
    Composite cmpTxtBoxes = new Composite(comp, SWT.NONE);
    cmpTxtBoxes.setLayout(twoColumnGridLayout);
    cmpTxtBoxes.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
    Label label;
    for (int i = 0; i < IDEPreferenceConstants.STAP_STRING_OPTIONS.length; i++) {
        label = new Label(cmpTxtBoxes, SWT.NONE);
        label.setText(IDEPreferenceConstants.STAP_STRING_OPTIONS[i][IDEPreferenceConstants.LABEL] + " (" + IDEPreferenceConstants.STAP_STRING_OPTIONS[i][IDEPreferenceConstants.FLAG] + // $NON-NLS-1$ //$NON-NLS-2$
        ")");
        label.setToolTipText(IDEPreferenceConstants.STAP_STRING_OPTIONS[i][IDEPreferenceConstants.TOOLTIP]);
        text[i] = new Text(cmpTxtBoxes, SWT.BORDER);
        text[i].setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, true));
        text[i].addModifyListener(modifyListener);
        text[i].setToolTipText(IDEPreferenceConstants.STAP_STRING_OPTIONS[i][IDEPreferenceConstants.TOOLTIP]);
        if (IDEPreferenceConstants.STAP_STRING_OPTIONS[i][IDEPreferenceConstants.FLAG].contains("-x")) {
            // $NON-NLS-1$
            this.targetPidText = text[i];
        }
    }
    label = new Label(cmpTxtBoxes, SWT.NONE);
    label.setText(Messages.SystemTapScriptOptionsTab_otherOptions);
    miscCommandsText = new Text(cmpTxtBoxes, SWT.BORDER);
    miscCommandsText.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, true));
    miscCommandsText.addModifyListener(modifyListener);
}
Also used : IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Image(org.eclipse.swt.graphics.Image) STAP_BOOLEAN_OPTIONS(org.eclipse.linuxtools.internal.systemtap.ui.ide.preferences.IDEPreferenceConstants.STAP_BOOLEAN_OPTIONS) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ExceptionErrorDialog(org.eclipse.linuxtools.systemtap.graphing.ui.widgets.ExceptionErrorDialog) IDEPlugin(org.eclipse.linuxtools.internal.systemtap.ui.ide.IDEPlugin) AbstractLaunchConfigurationTab(org.eclipse.debug.ui.AbstractLaunchConfigurationTab) Composite(org.eclipse.swt.widgets.Composite) AbstractUIPlugin(org.eclipse.ui.plugin.AbstractUIPlugin) IDEPreferenceConstants(org.eclipse.linuxtools.internal.systemtap.ui.ide.preferences.IDEPreferenceConstants) GridData(org.eclipse.swt.layout.GridData) Text(org.eclipse.swt.widgets.Text) STAP_CMD_OPTION(org.eclipse.linuxtools.internal.systemtap.ui.ide.preferences.IDEPreferenceConstants.STAP_CMD_OPTION) Button(org.eclipse.swt.widgets.Button) PlatformUI(org.eclipse.ui.PlatformUI) FileDialog(org.eclipse.swt.widgets.FileDialog) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) Group(org.eclipse.swt.widgets.Group) ModifyListener(org.eclipse.swt.events.ModifyListener) SWT(org.eclipse.swt.SWT) Platform(org.eclipse.core.runtime.Platform) KEY(org.eclipse.linuxtools.internal.systemtap.ui.ide.preferences.IDEPreferenceConstants.KEY) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Label(org.eclipse.swt.widgets.Label) SelectionListener(org.eclipse.swt.events.SelectionListener) GridLayout(org.eclipse.swt.layout.GridLayout) Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FileDialog(org.eclipse.swt.widgets.FileDialog) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 79 with FileDialog

use of org.eclipse.swt.widgets.FileDialog in project linuxtools by eclipse.

the class CreateVMPage method onSearchImage.

private SelectionListener onSearchImage() {
    return SelectionListener.widgetSelectedAdapter(e -> {
        FileDialog fd = new FileDialog(getShell());
        String location = fd.open();
        if (location != null && !location.isEmpty()) {
            model.setBoxRef(location);
        }
    });
}
Also used : FileDialog(org.eclipse.swt.widgets.FileDialog)

Example 80 with FileDialog

use of org.eclipse.swt.widgets.FileDialog in project linuxtools by eclipse.

the class STPEditor method queryFile.

private static File queryFile() {
    FileDialog dialog = new FileDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.SAVE);
    dialog.setText(Messages.NewFileHandler_NewFile);
    String path = dialog.open();
    if (path != null && !path.isEmpty()) {
        return new File(path);
    }
    return null;
}
Also used : FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File)

Aggregations

FileDialog (org.eclipse.swt.widgets.FileDialog)512 File (java.io.File)198 SelectionEvent (org.eclipse.swt.events.SelectionEvent)181 Button (org.eclipse.swt.widgets.Button)181 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)160 Label (org.eclipse.swt.widgets.Label)153 Text (org.eclipse.swt.widgets.Text)151 Composite (org.eclipse.swt.widgets.Composite)136 Shell (org.eclipse.swt.widgets.Shell)120 GridData (org.eclipse.swt.layout.GridData)110 ModifyListener (org.eclipse.swt.events.ModifyListener)109 ModifyEvent (org.eclipse.swt.events.ModifyEvent)107 GridLayout (org.eclipse.swt.layout.GridLayout)105 Group (org.eclipse.swt.widgets.Group)90 Event (org.eclipse.swt.widgets.Event)76 Listener (org.eclipse.swt.widgets.Listener)76 Display (org.eclipse.swt.widgets.Display)72 FormAttachment (org.eclipse.swt.layout.FormAttachment)68 FormData (org.eclipse.swt.layout.FormData)68 FormLayout (org.eclipse.swt.layout.FormLayout)68