org.eclipse.ui.internal.ide.dialogs.IDEResourceInfoUtils Java Examples
The following examples show how to use
org.eclipse.ui.internal.ide.dialogs.IDEResourceInfoUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RefreshHandler.java From gama with GNU General Public License v3.0 | 6 votes |
void checkLocationDeleted(final IProject project) throws CoreException { if (!project.exists()) { return; } final IFileInfo location = IDEResourceInfoUtils.getFileInfo(project.getLocationURI()); if (!location.exists()) { final String message = NLS.bind(IDEWorkbenchMessages.RefreshAction_locationDeletedMessage, project.getName(), location.toString()); final MessageDialog dialog = new MessageDialog(WorkbenchHelper.getShell(), IDEWorkbenchMessages.RefreshAction_dialogTitle, null, message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0) { @Override protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; WorkbenchHelper.run(() -> dialog.open()); // Do the deletion back in the operation thread if (dialog.getReturnCode() == 0) { // yes was chosen project.delete(true, true, null); } } }
Example #2
Source File: RefreshAction.java From gama with GNU General Public License v3.0 | 6 votes |
/** * Checks whether the given project's location has been deleted. If so, prompts the user with whether to delete the * project or not. */ void checkLocationDeleted(final IProject project) throws CoreException { if (!project.exists()) { return; } final IFileInfo location = IDEResourceInfoUtils.getFileInfo(project.getLocationURI()); if (!location.exists()) { final String message = NLS.bind(IDEWorkbenchMessages.RefreshAction_locationDeletedMessage, project.getName(), location.toString()); final MessageDialog dialog = new MessageDialog(WorkbenchHelper.getShell(), IDEWorkbenchMessages.RefreshAction_dialogTitle, null, message, QUESTION, new String[] { YES_LABEL, NO_LABEL }, 0) { @Override protected int getShellStyle() { return super.getShellStyle() | SHEET; } }; WorkbenchHelper.run(() -> dialog.open()); // Do the deletion back in the operation thread if (dialog.getReturnCode() == 0) { // yes was chosen project.delete(true, true, null); } } }
Example #3
Source File: FileFolderSelectionDialog.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
public IStatus validate(Object[] selection) { int nSelected = selection.length; String pluginId = IDEWorkbenchPlugin.IDE_WORKBENCH; if (nSelected == 0 || (nSelected > 1 && multiSelect == false)) { return new Status(IStatus.ERROR, pluginId, IStatus.ERROR, IDEResourceInfoUtils.EMPTY_STRING, null); } for (int i = 0; i < selection.length; i++) { Object curr = selection[i]; if (curr instanceof IFileStore) { IFileStore file = (IFileStore) curr; if (acceptFolders == false && file.fetchInfo().isDirectory()) { return new Status(IStatus.ERROR, pluginId, IStatus.ERROR, IDEResourceInfoUtils.EMPTY_STRING, null); } } } return Status.OK_STATUS; }
Example #4
Source File: FileFolderSelectionDialog.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
public IStatus validate(Object[] selection) { int nSelected = selection.length; String pluginId = IDEWorkbenchPlugin.IDE_WORKBENCH; if (nSelected == 0 || (nSelected > 1 && multiSelect == false)) { return new Status(IStatus.ERROR, pluginId, IStatus.ERROR, IDEResourceInfoUtils.EMPTY_STRING, null); } for (int i = 0; i < selection.length; i++) { Object curr = selection[i]; if (curr instanceof IFileStore) { IFileStore file = (IFileStore) curr; if (acceptFolders == false && file.fetchInfo().isDirectory()) { return new Status(IStatus.ERROR, pluginId, IStatus.ERROR, IDEResourceInfoUtils.EMPTY_STRING, null); } } } return Status.OK_STATUS; }
Example #5
Source File: FileFolderSelectionDialog.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
public Object[] getChildren(Object parentElement) { if (parentElement instanceof IFileStore) { IFileStore[] children = IDEResourceInfoUtils.listFileStores( (IFileStore) parentElement, fileFilter, new NullProgressMonitor()); if (children != null) { return children; } } return EMPTY; }
Example #6
Source File: FileFolderSelectionDialog.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
public Object[] getChildren(Object parentElement) { if (parentElement instanceof IFileStore) { IFileStore[] children = IDEResourceInfoUtils.listFileStores( (IFileStore) parentElement, fileFilter, new NullProgressMonitor()); if (children != null) { return children; } } return EMPTY; }
Example #7
Source File: CopyFilesAndFoldersOperation.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * Checks whether the resources with the given names exist. * * @param resources * IResources to checl * @return Multi status with one error message for each missing file. */ IStatus checkExist(IResource[] resources) { MultiStatus multiStatus = new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, getProblemsMessage(), null); for (int i = 0; i < resources.length; i++) { IResource resource = resources[i]; if (resource != null) { URI location = resource.getLocationURI(); String message = null; if (location != null) { IFileInfo info = IDEResourceInfoUtils.getFileInfo(location); if (info == null || info.exists() == false) { if (resource.isLinked()) { message = NLS.bind(IDEWorkbenchMessages.CopyFilesAndFoldersOperation_missingLinkTarget, resource.getName()); } else { message = NLS.bind(IDEWorkbenchMessages.CopyFilesAndFoldersOperation_resourceDeleted, resource.getName()); } } } if (message != null) { IStatus status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, message, null); multiStatus.add(status); } } } return multiStatus; }
Example #8
Source File: CopyFilesAndFoldersOperation.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * Build the collection of fileStores that map to fileNames. If any of them * cannot be found then match then return null. * * @param fileNames * @return IFileStore[] */ private IFileStore[] buildFileStores(final String[] fileNames) { IFileStore[] stores = new IFileStore[fileNames.length]; for (int i = 0; i < fileNames.length; i++) { IFileStore store = IDEResourceInfoUtils.getFileStore(fileNames[i]); if (store == null) { reportFileInfoNotFound(fileNames[i]); return null; } stores[i] = store; } return stores; }
Example #9
Source File: CopyFilesAndFoldersOperation.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * Checks whether the destination is valid for copying the source files. * <p> * Note this method is for internal use only. It is not API. * </p> * * @param destination * the destination container * @param sourceNames * the source file names * @return an error message, or <code>null</code> if the path is valid */ public String validateImportDestination(IContainer destination, String[] sourceNames) { IFileStore[] stores = new IFileStore[sourceNames.length]; for (int i = 0; i < sourceNames.length; i++) { IFileStore store = IDEResourceInfoUtils.getFileStore(sourceNames[i]); if (store == null) { return NLS.bind(IDEWorkbenchMessages.CopyFilesAndFoldersOperation_infoNotFound, sourceNames[i]); } stores[i] = store; } return validateImportDestinationInternal(destination, stores); }
Example #10
Source File: SyncGraphvizExportHandler.java From gef with Eclipse Public License 2.0 | 4 votes |
private void exportGraph(IFile inputFile) { /** * do not try to export an empty dot file */ boolean isEmpty = "0 bytes" //$NON-NLS-1$ .equals(IDEResourceInfoUtils.getSizeString(inputFile)); if (isEmpty) { return; } File resolvedInputFile = null; try { resolvedInputFile = DotFileUtils .resolve(inputFile.getLocationURI().toURL()); } catch (MalformedURLException e) { DotActivatorEx.logError(e); return; } String dotExportFormat = GraphvizPreferencePage.getDotExportFormat(); if (dotExportFormat.isEmpty()) { return; } String[] outputs = new String[2]; File outputFile = DotExecutableUtils.renderImage( new File(GraphvizPreferencePage.getDotExecutablePath()), resolvedInputFile, dotExportFormat, null, outputs); // whenever the dot executable call produced any error message, show it // to the user within an error message box if (!outputs[1].isEmpty()) { Display.getDefault().asyncExec(new Runnable() { @Override public void run() { MessageDialog.openError( Display.getDefault().getActiveShell(), "Errors from dot call:", outputs[1]); //$NON-NLS-1$ } }); } // refresh the parent folder and open the output file if the export // was successful if (outputFile != null) { IFile outputEclipseFile = convertToEclipseFile(outputFile); if (outputEclipseFile != null) { refreshParent(outputEclipseFile); if (GraphvizPreferencePage .getDotOpenExportedFileAutomaticallyValue()) { openFile(outputEclipseFile); } } } }
Example #11
Source File: ProjectContentsLocationArea.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
/** * Create the area for user entry. * * @param composite * @param defaultEnabled */ private void createUserEntryArea(Composite composite, boolean defaultEnabled) { // location label locationLabel = new Label(composite, SWT.NONE); locationLabel.setText(IDEWorkbenchMessages.ProjectLocationSelectionDialog_locationLabel); // project location entry field locationPathField = new Text(composite, SWT.BORDER); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.widthHint = SIZING_TEXT_FIELD_WIDTH; data.horizontalSpan = 2; locationPathField.setLayoutData(data); // browse button browseButton = new Button(composite, SWT.PUSH); browseButton.setText(BROWSE_LABEL); browseButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { handleLocationBrowseButtonPressed(); } }); createFileSystemSelection(composite); if (defaultEnabled) { locationPathField.setText(TextProcessor.process(getDefaultPathDisplayString())); } else { if (existingProject == null) { locationPathField.setText(IDEResourceInfoUtils.EMPTY_STRING); } else { locationPathField.setText(TextProcessor.process(existingProject.getLocation().toOSString())); } } locationPathField.addModifyListener(new ModifyListener() { /* * (non-Javadoc) * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent) */ public void modifyText(ModifyEvent e) { errorReporter.reportError(checkValidLocation(), false); } }); }
Example #12
Source File: ProjectContentsLocationArea.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
/** * Open an appropriate directory browser */ private void handleLocationBrowseButtonPressed() { String selectedDirectory = null; String dirName = getPathFromLocationField(); if (!dirName.equals(IDEResourceInfoUtils.EMPTY_STRING)) { IFileInfo info; info = IDEResourceInfoUtils.getFileInfo(dirName); if (info == null || !(info.exists())) dirName = IDEResourceInfoUtils.EMPTY_STRING; } else { String value = getDialogSettings().get(SAVED_LOCATION_ATTR); if (value != null) { dirName = value; } } FileSystemConfiguration config = getSelectedConfiguration(); if (config == null || config.equals(FileSystemSupportRegistry.getInstance().getDefaultConfiguration())) { DirectoryDialog dialog = new DirectoryDialog(locationPathField.getShell(), SWT.SHEET); dialog.setMessage(IDEWorkbenchMessages.ProjectLocationSelectionDialog_directoryLabel); dialog.setFilterPath(dirName); selectedDirectory = dialog.open(); } else { URI uri = getSelectedConfiguration().getContributor().browseFileSystem(dirName, browseButton.getShell()); if (uri != null) selectedDirectory = uri.toString(); } if (selectedDirectory != null) { updateLocationField(selectedDirectory); getDialogSettings().put(SAVED_LOCATION_ATTR, selectedDirectory); } }