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()); } } }); }
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)); } } }; }
@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; }
@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; }
/** * 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()); } }
@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()); } } }); }
/** * 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; }
@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; }
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(); } }
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); } } } }
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()); } } }
@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; }
@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); } }
/** * 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()); } } }