Java 类org.eclipse.ui.dialogs.FilteredResourcesSelectionDialog 实例源码

项目:PDFReporter-Studio    文件:SPImageProvider.java   
protected void createComponent(Composite parent) {
    super.createComponent(parent);

    btn = section.getWidgetFactory().createButton(parent, "...", SWT.PUSH);
    btn.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            FilteredResourcesSelectionDialog dialog = new FilteredResourcesSelectionDialog(ftext.getShell(), false, ResourcesPlugin.getWorkspace().getRoot(), IResource.FILE);
            dialog.setTitle(Messages.ResourceCellEditor_open_resource);
            dialog.setInitialPattern("*.*"); //$NON-NLS-1$
            if (dialog.open() == Window.OK) {
                IFile file = (IFile) dialog.getFirstResult();
                if (file != null)
                    handleTextChanged(section, pDescriptor.getId(), file.getRawLocation().toOSString());
            }
        }
    });
}
项目:PDFReporter-Studio    文件:SPResourceType.java   
protected SelectionAdapter buttonPressed(){
    return new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            FilteredResourcesSelectionDialog dialog = new FilteredResourcesSelectionDialog(ftext.getShell(), false,
                    ResourcesPlugin.getWorkspace().getRoot(), IResource.FILE);
            dialog.setTitle(Messages.ResourceCellEditor_open_resource);
            dialog.setInitialPattern("*.properties"); //$NON-NLS-1$
            if (dialog.open() == Window.OK) {
                IFile file = (IFile) dialog.getFirstResult();
                if (file != null)
                    handleTextChanged(section, pDescriptor.getId(), convertFile2Value(file));
            }
        }
    };
}
项目:PDFReporter-Studio    文件:ResourceCellEditor.java   
@Override
protected Object openDialogBox(Control cellEditorWindow) {
    Shell shell = cellEditorWindow.getShell();
    FilteredResourcesSelectionDialog dialog = new FilteredResourcesSelectionDialog(shell, false, ResourcesPlugin
            .getWorkspace().getRoot(), IResource.FILE);
    dialog.setTitle(Messages.ResourceCellEditor_open_resource);
    dialog.setInitialPattern("*.properties"); //$NON-NLS-1$
    // dialog.setMessage("Please choose the Resource bundle:");
    // dialog.setMessage("Enter the name prefix or pattern (?, *, or camel case)");
    if (dialog.open() == Window.OK) {
        IFile file = (IFile) dialog.getFirstResult();
        if (file != null)
            return convertFile2Value(file);
    }
    return null;
}
项目:PDFReporter-Studio    文件:FileElement.java   
@Override
public Control createControl(Composite parent) {
    bbuton = new Button(parent, SWT.PUSH);
    bbuton.setText(Messages.FileInput_selectfile);
    bbuton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            FilteredResourcesSelectionDialog fd = new FilteredResourcesSelectionDialog(Display.getCurrent()
                    .getActiveShell(), false, ResourcesPlugin.getWorkspace().getRoot(), IResource.FILE);
            if (fd.open() == Dialog.OK) {
                IFile file = (IFile) fd.getFirstResult();
                setValue(new File(file.getLocationURI()));
                updateLabel();
            }
        }
    });
    if (getValue() != null && getValue() instanceof Boolean)
        bbuton.setSelection((Boolean) Misc.nvl(getValue(), Boolean.FALSE));
    updateLabel();
    return bbuton;
}
项目:gmm-eclipse-plugins    文件:GMMRunconfigTab.java   
/**
 * Handles the project browse button.
 */
private void handleBrowse() {
    FilteredItemsSelectionDialog dialog = new FilteredResourcesSelectionDialog(getShell(), false,
            ResourcesPlugin.getWorkspace().getRoot(), IResource.PROJECT);
    dialog.setTitle("Browse...");
    String path = project.getText();
    if (path != null && path.length() > 0 && new Path(path).lastSegment().length() > 0) {
        dialog.setInitialPattern(new Path(path).lastSegment());
    } else {
        dialog.setInitialPattern("**");
    }
    dialog.open();
    if (dialog.getResult() != null && dialog.getResult().length > 0
            && dialog.getResult()[0] instanceof IProject) {
        project.setText(((IProject)dialog.getResult()[0]).getFullPath().toString());
    }
}
项目:PDFReporter-Studio    文件:FileSelectionPage.java   
@Override
public void createControl(Composite parent) {
    final Composite cmp = new Composite(parent, SWT.NONE);
    setControl(cmp);
    cmp.setLayout(new GridLayout(2, false));

    Label lbl = new Label(cmp, SWT.NONE);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    lbl.setLayoutData(gd);

    final Text tfile = new Text(cmp, SWT.BORDER | SWT.READ_ONLY);
    tfile.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Button b = new Button(cmp, SWT.PUSH);
    b.setText(Messages.common_browse);
    b.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            FilteredResourcesSelectionDialog dialog = new FilteredResourcesSelectionDialog(UIUtils.getShell(), false, ResourcesPlugin.getWorkspace().getRoot(), IResource.FILE);
            dialog.setTitle(Messages.ResourceCellEditor_open_resource);
            dialog.setInitialPattern("*.jrxml"); //$NON-NLS-1$
            if (dialog.open() == Window.OK) {
                file = (IFile) dialog.getFirstResult();
                tfile.setText(file.getFullPath().toOSString());
            }
        }
    });
}
项目:PDFReporter-Studio    文件:AFileResourcePageContent.java   
/**
 * Return a resource by selecting it from the workspace
 * 
 * @return the path of the resource
 */
protected String getResourceDialog() {
    FilteredResourcesSelectionDialog dialog = new FilteredResourcesSelectionDialog(trefuri.getShell(), false, ResourcesPlugin.getWorkspace().getRoot(), IResource.FILE);
    dialog.setTitle("");
    dialog.setInitialPattern(getIntialPattern()); //$NON-NLS-1$
    if (dialog.open() == Window.OK) {
        IFile file = (IFile) dialog.getFirstResult();
        return file.getLocation().toPortableString();
    }
    return null;
}
项目:PDFReporter-Studio    文件:ImageProviderCellEditor.java   
@Override
protected Object openDialogBox(Control cellEditorWindow) {
    Shell shell = cellEditorWindow.getShell();
    FilteredResourcesSelectionDialog dialog = new FilteredResourcesSelectionDialog(shell, false, ResourcesPlugin.getWorkspace().getRoot(), IResource.FILE);
    dialog.setTitle(Messages.ResourceCellEditor_open_resource);
    dialog.setInitialPattern("*.*"); //$NON-NLS-1$
    // dialog.setMessage("Please choose the Resource bundle:");
    // dialog.setMessage("Enter the name prefix or pattern (?, *, or camel case)");
    if (dialog.open() == Window.OK) {
        IFile file = (IFile) dialog.getFirstResult();
        if (file != null)
            return file.getRawLocation().toOSString();
    }
    return null;
}
项目:PDFReporter-Studio    文件:ImageSelectionDialog.java   
private void selectImageFromWorkspace() {
    FilteredResourcesSelectionDialog fd = new FilteredResourcesSelectionDialog(Display.getCurrent().getActiveShell(),
            false, ResourcesPlugin.getWorkspace().getRoot(), IResource.FILE);
    fd.setInitialPattern("*.png");//$NON-NLS-1$
    if (fd.open() == Dialog.OK) {
        IFile file = (IFile) fd.getFirstResult();
        IFile contextfile = (IFile) jConfig.get(FileUtils.KEY_FILE);
        String filepath = null;
        if (contextfile != null && file.getProject().equals(contextfile.getProject()))
            filepath = file.getProjectRelativePath().toPortableString().replaceAll(file.getProject().getName() + "/", ""); //$NON-NLS-1$ //$NON-NLS-2$
        else
            filepath = file.getRawLocationURI().toASCIIString();
        txtResourcePath.setText(filepath);
        try {
            IFileStore imgFileStore = EFS.getStore(file.getLocationURI());
            loadImagePreview(file.getLocation().toOSString(), imgFileStore);
            // Change the standard separator with an universal one
            imageExpressionText = file.getLocation().toOSString()
                    .replace(System.getProperty("file.separator").charAt(0), '/');
        } catch (CoreException e) {
            UIUtils.showError(e);
        }
    } else {
        // no image selected
        txtResourcePath.setText(""); //$NON-NLS-1$
        grpImagePreviewLayout.topControl = cmpNoImgPreview;
        grpImagePreview.layout();
    }
}
项目:PDFReporter-Studio    文件:CreateStyleTemplateCommand.java   
private void createObject() {
    if (jrTemplate == null) {
        FilteredResourcesSelectionDialog fd = new FilteredHelpDialog(Display.getCurrent().getActiveShell(),false, ResourcesPlugin.getWorkspace().getRoot(), IResource.FILE);
        fd.setInitialPattern("*.jrtx");//$NON-NLS-1$
        if (fd.open() == Dialog.OK) {
            IFile file = (IFile) fd.getFirstResult();
            File  fileToBeOpened = file.getRawLocation().makeAbsolute().toFile();
            boolean showErrorMessage = false;
            //Check if the file is a valid template before add it to the model
            if (fileToBeOpened != null && fileToBeOpened.exists() && fileToBeOpened.isFile()) {
                try{
                    //Try to load the file to see if it is a valid template
                    JRXmlTemplateLoader.load(fileToBeOpened);
                    this.jrTemplate = MStyleTemplate.createJRTemplate();
                    JRDesignExpression jre = new JRDesignExpression();
                    jre.setText("\"" + getStylePath(file) + "\"");//$NON-NLS-1$ //$NON-NLS-2$
                    ((JRDesignReportTemplate) jrTemplate).setSourceExpression(jre);
                } catch(Exception ex){
                    showErrorMessage = true;
                }
            } else {
                showErrorMessage = true;
            }
            if (showErrorMessage){
                MessageDialog.open(MessageDialog.ERROR, Display.getCurrent().getActiveShell(), Messages.UIUtils_ExceptionTitle, Messages.CreateStyleTemplateCommand_loadStyleError, SWT.NONE);
            }
        }
    }
}
项目:PDFReporter-Studio    文件:CreateStyleTemplateReferenceCommand.java   
private void createObject() {
    if (jrTemplate == null) {
        FilteredResourcesSelectionDialog fd = new FilteredResourcesSelectionDialog(Display.getCurrent().getActiveShell(),
                false, ResourcesPlugin.getWorkspace().getRoot(), IResource.FILE);
        fd.setInitialPattern("*.jrtx");//$NON-NLS-1$
        if (fd.open() == Dialog.OK) {
            IFile file = (IFile) fd.getFirstResult();

            this.jrTemplate = MStyleTemplateReference.createJRTemplate();
            jrTemplate.setLocation(file.getProjectRelativePath().toPortableString());

        }
    }
}
项目:PDFReporter-Studio    文件:ImageElement.java   
@Override
public Control createControl(Composite parent) {
    bbuton = new Button(parent, SWT.PUSH);
    bbuton.setText(Messages.ImageInput_selectimage);
    bbuton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            FilteredResourcesSelectionDialog fd = new FilteredResourcesSelectionDialog(Display.getCurrent()
                    .getActiveShell(), false, ResourcesPlugin.getWorkspace().getRoot(), IResource.FILE);
            fd.setInitialPattern("*.png");//$NON-NLS-1$
            if (fd.open() == Dialog.OK) {
                IFile file = (IFile) fd.getFirstResult();
                Image image;
                try {
                    image = ImageIO.read(file.getContents());
                    setValue(image);
                    updateLabel();
                } catch (Exception e1) {
                    UIUtils.showError(e1);
                }
            }
        }
    });
    if (getValue() != null && getValue() instanceof Boolean)
        bbuton.setSelection((Boolean) Misc.nvl(getValue(), Boolean.FALSE));
    updateLabel();
    return bbuton;
}
项目:PDFReporter-Studio    文件:FileInput.java   
@Override
public void createInput(Composite parent, final IParameter param, final Map<String, Object> params) {
    super.createInput(parent, param, params);
    if (isForType(param.getValueClass())) {
        btn = new Button(parent, SWT.PUSH);
        btn.setText(Messages.FileInput_selectfile);
        btn.setToolTipText(param.getDescription());
        btn.addFocusListener(focusListener);
        btn.setAlignment(SWT.LEFT);
        GridData gd = new GridData();
        gd.heightHint = 70;
        btn.setLayoutData(gd);
        btn.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                FilteredResourcesSelectionDialog fd = new FilteredResourcesSelectionDialog(Display.getCurrent()
                        .getActiveShell(), false, ResourcesPlugin.getWorkspace().getRoot(), IResource.FILE);
                if (fd.open() == Dialog.OK) {
                    IFile file = (IFile) fd.getFirstResult();
                    updateModel(new File(file.getLocationURI()));
                }
            }

        });
        updateInput();
        setNullable(param, btn);
    }
}
项目:gama    文件:NewExperimentWizardPage.java   
/**
 * Uses the standard container selection dialog to choose the new value for the container field.
 * 
 * @throws CoreException
 */
private void handleBrowse() {
    final IContainer p = ResourcesPlugin.getWorkspace().getRoot();
    dialog = new FilteredResourcesSelectionDialog(getShell(), false, p, Resource.FILE);
    dialog.setInitialPattern("*.gaml");
    dialog.setTitle("Choose a gaml model in project " + p.getName());
    if (dialog.open() == Window.OK) {
        final Object[] result = dialog.getResult();
        if (result.length == 1) {
            final IResource res = (IResource) result[0];
            modelChooser.setText(res.getFullPath().toString());
        }
    }
}