Java Code Examples for org.eclipse.ui.PlatformUI#PLUGIN_ID

The following examples show how to use org.eclipse.ui.PlatformUI#PLUGIN_ID . 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: FilteredItemsSelectionDialog.java    From tlaplus with MIT License 6 votes vote down vote up
public IStatus runInUIThread(IProgressMonitor monitor) {

			if (!progressLabel.isDisposed())
				progressLabel.setText(progressMonitor != null ? progressMonitor
						.getMessage() : EMPTY_STRING);

			if (progressMonitor == null || progressMonitor.isDone()) {
				return new Status(IStatus.CANCEL, PlatformUI.PLUGIN_ID,
						IStatus.CANCEL, EMPTY_STRING, null);
			}

			// Schedule cyclical with 500 milliseconds delay
			schedule(500);

			return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, IStatus.OK,
					EMPTY_STRING, null);
		}
 
Example 2
Source File: PyResourceDropAdapterAssistant.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Performs a resource copy
 */
private IStatus performResourceCopy(CommonDropAdapter dropAdapter, Shell shell, IResource[] sources) {
    MultiStatus problems = new MultiStatus(PlatformUI.PLUGIN_ID, 1,
            WorkbenchNavigatorMessages.DropAdapter_problemsMoving, null);
    mergeStatus(
            problems,
            validateTarget(getCurrentTarget(dropAdapter), dropAdapter.getCurrentTransfer(),
                    dropAdapter.getCurrentOperation()));

    IContainer target = getActualTarget((IResource) getCurrentTarget(dropAdapter));
    CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(shell);
    IResource[] copiedResources = operation.copyResources(sources, target);
    if (copiedResources.length > 0) {
        PythonPathHelper.updatePyPath(copiedResources, target, PythonPathHelper.OPERATION_COPY);
    }

    return problems;
}
 
Example 3
Source File: ResourceDropAdapterAssistant.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Performs a drop using the FileTransfer transfer type.
 */
private IStatus performFileDrop(final CommonDropAdapter anAdapter, Object data) {
	final int currentOperation = anAdapter.getCurrentOperation();
	MultiStatus problems = new MultiStatus(PlatformUI.PLUGIN_ID, 0,
			WorkbenchNavigatorMessages.resources_ResourceDropAdapterAssistant_problemImporting, null);
	mergeStatus(problems,
			validateTarget(anAdapter.getCurrentTarget(), anAdapter
					.getCurrentTransfer(), currentOperation));

	final IContainer target = getActualTarget((IResource) anAdapter
			.getCurrentTarget());
	final String[] names = (String[]) data;
	// Run the import operation asynchronously.
	// Otherwise the drag source (e.g., Windows Explorer) will be blocked
	// while the operation executes. Fixes bug 16478.
	Display.getCurrent().asyncExec(new Runnable() {
		public void run() {
			getShell().forceActive();
			new CopyFilesAndFoldersOperation(getShell()).copyOrLinkFiles(names, target, currentOperation);
		}
	});
	return problems;
}
 
Example 4
Source File: PyResourceDropAdapterAssistant.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Performs a drop using the FileTransfer transfer type.
 */
private IStatus performFileDrop(CommonDropAdapter anAdapter, Object data) {
    data = getActual(data);
    MultiStatus problems = new MultiStatus(PlatformUI.PLUGIN_ID, 0,
            WorkbenchNavigatorMessages.DropAdapter_problemImporting, null);
    mergeStatus(
            problems,
            validateTarget(getCurrentTarget(anAdapter), anAdapter.getCurrentTransfer(),
                    anAdapter.getCurrentOperation()));

    final IContainer target = getActualTarget((IResource) getCurrentTarget(anAdapter));
    final String[] names = (String[]) data;
    // Run the import operation asynchronously.
    // Otherwise the drag source (e.g., Windows Explorer) will be blocked
    // while the operation executes. Fixes bug 16478.
    Display.getCurrent().asyncExec(new Runnable() {
        @Override
        public void run() {
            getShell().forceActive();
            CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(getShell());
            operation.copyFiles(names, target);
        }
    });
    return problems;
}
 
Example 5
Source File: ResourceDropAdapterAssistant.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Performs a drop using the FileTransfer transfer type.
 */
private IStatus performFileDrop(final CommonDropAdapter anAdapter, Object data) {
	final int currentOperation = anAdapter.getCurrentOperation();
	MultiStatus problems = new MultiStatus(PlatformUI.PLUGIN_ID, 0,
			WorkbenchNavigatorMessages.resources_ResourceDropAdapterAssistant_problemImporting, null);
	mergeStatus(problems,
			validateTarget(anAdapter.getCurrentTarget(), anAdapter
					.getCurrentTransfer(), currentOperation));

	final IContainer target = getActualTarget((IResource) anAdapter
			.getCurrentTarget());
	final String[] names = (String[]) data;
	// Run the import operation asynchronously.
	// Otherwise the drag source (e.g., Windows Explorer) will be blocked
	// while the operation executes. Fixes bug 16478.
	Display.getCurrent().asyncExec(new Runnable() {
		public void run() {
			getShell().forceActive();
			new CopyFilesAndFoldersOperation(getShell()).copyOrLinkFiles(names, target, currentOperation);
		}
	});
	return problems;
}
 
Example 6
Source File: NavigatorResourceDropAssistant.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Performs a drop using the FileTransfer transfer type.
 */
private IStatus performFileDrop(final CommonDropAdapter anAdapter, final Object data) {
	final int currentOperation = anAdapter.getCurrentOperation();
	final MultiStatus problems =
			new MultiStatus(PlatformUI.PLUGIN_ID, 0, WorkbenchNavigatorMessages.DropAdapter_problemImporting, null);
	mergeStatus(problems,
			validateTarget(anAdapter.getCurrentTarget(), anAdapter.getCurrentTransfer(), currentOperation));

	final IContainer target = getActualTarget(ResourceManager.getResource(anAdapter.getCurrentTarget()));
	final String[] names = (String[]) data;
	// Run the import operation asynchronously.
	// Otherwise the drag source (e.g., Windows Explorer) will be blocked
	// while the operation executes. Fixes bug 16478.
	Display.getCurrent().asyncExec(() -> {
		getShell().forceActive();
		new CopyFilesAndFoldersOperation(getShell()).copyOrLinkFiles(names, target, currentOperation);
	});
	return problems;
}
 
Example 7
Source File: ModelWriter.java    From tlaplus with MIT License 6 votes vote down vote up
/**
    * Write the content to files
    * @param tlaFile
    * @param cfgFile
    * @param monitor
    * @throws CoreException
    */
public void writeFiles(final IFile tlaFile, final IFile cfgFile, final IProgressMonitor monitor) throws CoreException {
	final ContentWriter cw = (inputStream, forTLAFile) -> {
		final IFile file = forTLAFile ? tlaFile : cfgFile;
		
		if (file.exists()) {
			try {
				file.setContents(inputStream, IResource.FORCE, monitor);
			} catch (final CoreException ce) {
				throw new IOException("Exception writing file " + ce.getMessage(), ce);
			}
		} else {
			throw new IOException("Expected file " + file.getName() + " has been removed externally.");
		}
	};
	
	try {
		super.writeFiles(cw);
	} catch (final IOException e) {
		throw new CoreException(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.ERROR,
								"Exception encountered attempting to write modules for the model checking.", e));
	}
   }
 
Example 8
Source File: TraceExpressionModelWriter.java    From tlaplus with MIT License 6 votes vote down vote up
/**
    * Write the content to files
    * @param tlaFile
    * @param cfgFile
    * @param monitor
    * @throws CoreException
    */
public void writeFiles(final IFile tlaFile, final IFile cfgFile, final IProgressMonitor monitor) throws CoreException {
	final ContentWriter cw = (inputStream, forTLAFile) -> {
		final IFile file = forTLAFile ? tlaFile : cfgFile;
		
		if (file.exists()) {
			try {
				file.setContents(inputStream, IResource.FORCE, monitor);
			} catch (final CoreException ce) {
				throw new IOException("Exception writing file " + ce.getMessage(), ce);
			}
		} else {
			throw new IOException("Expected file " + file.getName() + " has been removed externally.");
		}
	};
	
	try {
		super.writeFiles(cw);
	} catch (final IOException e) {
		throw new CoreException(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.ERROR,
								"Exception encountered attempting to write modules for the model checking.", e));
	}
   }
 
Example 9
Source File: FilteredItemsSelectionDialog.java    From tlaplus with MIT License 6 votes vote down vote up
protected IStatus run(IProgressMonitor monitor) {
	if (monitor.isCanceled()) {
		return new Status(IStatus.CANCEL, WorkbenchPlugin.PI_WORKBENCH,
				IStatus.CANCEL, EMPTY_STRING, null);
	}

	if (FilteredItemsSelectionDialog.this != null) {
		GranualProgressMonitor wrappedMonitor = new GranualProgressMonitor(
				monitor);
		FilteredItemsSelectionDialog.this.reloadCache(true,
				wrappedMonitor);
	}

	if (!monitor.isCanceled()) {
		refreshJob.schedule();
	}

	return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, IStatus.OK,
			EMPTY_STRING, null);

}
 
Example 10
Source File: RenameResourceAction.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected IRunnableWithProgress createOperation(final IStatus[] errorStatus) {
	return monitor -> {
		final IResource[] resources = getActionResources().toArray(new IResource[getActionResources().size()]);
		// Rename is only valid for a single resource. This has already
		// been validated.
		if (resources.length == 1) {
			// check for overwrite
			final IWorkspaceRoot workspaceRoot = resources[0].getWorkspace().getRoot();
			final IResource newResource = workspaceRoot.findMember(newPath);
			boolean go = true;
			if (newResource != null) {
				go = checkOverwrite(WorkbenchHelper.getShell(), newResource);
			}
			if (go) {
				final MoveResourcesOperation op = new MoveResourcesOperation(resources[0], newPath,
						IDEWorkbenchMessages.RenameResourceAction_operationTitle);
				op.setModelProviderIds(getModelProviderIds());
				try {
					PlatformUI.getWorkbench().getOperationSupport().getOperationHistory().execute(op, monitor,
							WorkspaceUndoUtil.getUIInfoAdapter(WorkbenchHelper.getShell()));
				} catch (final ExecutionException e) {
					if (e.getCause() instanceof CoreException) {
						errorStatus[0] = ((CoreException) e.getCause()).getStatus();
					} else {
						errorStatus[0] = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, getProblemsMessage(), e);
					}
				}
			}
		}
	};
}
 
Example 11
Source File: FilteredItemsSelectionDialog.java    From tlaplus with MIT License 5 votes vote down vote up
/**
 * Executes job using the given filtering progress monitor. A hook for
 * subclasses.
 *
 * @param monitor
 *            progress monitor
 * @return result of the execution
 */
protected IStatus doRun(GranualProgressMonitor monitor) {
	try {
		internalRun(monitor);
	} catch (CoreException e) {
		cancel();
		return new Status(
				IStatus.ERROR,
				PlatformUI.PLUGIN_ID,
				IStatus.ERROR,
				WorkbenchMessages.FilteredItemsSelectionDialog_jobError,
				e);
	}
	return Status.OK_STATUS;
}
 
Example 12
Source File: MongoDBAdvancedSettingsDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private Status getMiscStatus( int severity, String message )
{
	return new Status( severity,
			PlatformUI.PLUGIN_ID,
			severity,
			message,
			null );
}
 
Example 13
Source File: CopyFilesAndFoldersOperation.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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 14
Source File: MethodParameterDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private Status getMiscStatus( int severity, String message )
{
	return new Status( severity,
			PlatformUI.PLUGIN_ID,
			severity,
			message,
			null );
}
 
Example 15
Source File: ColumnMappingDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private Status getMiscStatus( int severity, String message )
{
	return new Status( severity,
			PlatformUI.PLUGIN_ID,
			severity,
			message,
			null );
}
 
Example 16
Source File: CopyFilesAndFoldersOperation.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Checks whether the infos exist.
 *
 * @param stores
 *            the file infos to test
 * @return Multi status with one error message for each missing file.
 */
IStatus checkExist(IFileStore[] stores) {
    MultiStatus multiStatus = new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, getProblemsMessage(), null);

    for (int i = 0; i < stores.length; i++) {
        if (stores[i].fetchInfo().exists() == false) {
            String message = NLS.bind(IDEWorkbenchMessages.CopyFilesAndFoldersOperation_resourceDeleted,
                    stores[i].getName());
            IStatus status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, message, null);
            multiStatus.add(status);
        }
    }
    return multiStatus;
}
 
Example 17
Source File: RenameResourceAndCloseEditorAction.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
protected IRunnableWithProgress createOperation(final IStatus[] errorStatus) {
	return new IRunnableWithProgress() {
		public void run(IProgressMonitor monitor) {
			IResource[] resources = (IResource[]) getActionResources()
					.toArray(new IResource[getActionResources().size()]);
			// Rename is only valid for a single resource. This has already
			// been validated.
			if (resources.length == 1) {
				// check for overwrite
				IWorkspaceRoot workspaceRoot = resources[0].getWorkspace()
						.getRoot();
				IResource newResource = workspaceRoot.findMember(newPath);
				boolean go = true;
				if (newResource != null) {
					go = checkOverwrite(shellProvider.getShell(), newResource);
				}
				if (go) {
					MoveResourcesOperation op = new MoveResourcesOperation(
							resources[0],
							newPath,
							IDEWorkbenchMessages.RenameResourceAction_operationTitle);
					op.setModelProviderIds(getModelProviderIds());
					try {
						PlatformUI
								.getWorkbench()
								.getOperationSupport()
								.getOperationHistory()
								.execute(
										op,
										monitor,
										WorkspaceUndoUtil
												.getUIInfoAdapter(shellProvider.getShell()));
					} catch (ExecutionException e) {
						if (e.getCause() instanceof CoreException) {
							errorStatus[0] = ((CoreException) e.getCause())
									.getStatus();
						} else {
							errorStatus[0] = new Status(IStatus.ERROR,
									PlatformUI.PLUGIN_ID,
									getProblemsMessage(), e);
						}
					}
				}
			}
		}
	};
}
 
Example 18
Source File: ResourceDropAdapterAssistant.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
	 * Performs a resource copy
	 */
	private IStatus performResourceCopy(CommonDropAdapter dropAdapter,
			Shell shell, IResource[] sources) {
		MultiStatus problems = new MultiStatus(PlatformUI.PLUGIN_ID, 1,
				WorkbenchNavigatorMessages.resources_ResourceDropAdapterAssistant_problemsMoving, null);
		mergeStatus(problems, validateTarget(dropAdapter.getCurrentTarget(), dropAdapter.getCurrentTransfer(),
				dropAdapter.getCurrentOperation()));

		IContainer target = getActualTarget((IResource) dropAdapter.getCurrentTarget());

		boolean shouldLinkAutomatically = false;
		if (target.isVirtual()) {
			shouldLinkAutomatically = true;
			for (int i = 0; i < sources.length; i++) {
				if ((sources[i].getType() != IResource.FILE) && (sources[i].getLocation() != null)) {
					// If the source is a folder, but the location is null (a
					// broken link, for example),
					// we still generate a link automatically (the best option).
					shouldLinkAutomatically = false;
					break;
				}
			}
		}

		CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(shell);
		// if the target is a virtual folder and all sources are files, then
		// automatically create links
		if (shouldLinkAutomatically) {
			operation.setCreateLinks(true);
			operation.copyResources(sources, target);
		} else {
//			boolean allSourceAreLinksOrVirtualFolders = true;
//			for (int i = 0; i < sources.length; i++) {
//				if (!sources[i].isVirtual() && !sources[i].isLinked()) {
//					allSourceAreLinksOrVirtualFolders = false;
//					break;
//				}
//			}
//			// if all sources are either links or groups, copy then normally,
//			// don't show the dialog
//			if (!allSourceAreLinksOrVirtualFolders) {
//				IPreferenceStore store= IDEWorkbenchPlugin.getDefault().getPreferenceStore();
//				String dndPreference= store.getString(target.isVirtual() ? IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_VIRTUAL_FOLDER_MODE : IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE);
//
//				if (dndPreference.equals(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_PROMPT)) {
//					ImportTypeDialog dialog = new ImportTypeDialog(getShell(), dropAdapter.getCurrentOperation(), sources, target);
//					dialog.setResource(target);
//					if (dialog.open() == Window.OK) {
//						if (dialog.getSelection() == ImportTypeDialog.IMPORT_VIRTUAL_FOLDERS_AND_LINKS)
//							operation.setVirtualFolders(true);
//						if (dialog.getSelection() == ImportTypeDialog.IMPORT_LINK)
//							operation.setCreateLinks(true);
//						if (dialog.getVariable() != null)
//							operation.setRelativeVariable(dialog.getVariable());
//						operation.copyResources(sources, target);
//					} else
//						return problems;
//				}
//				else
//					operation.copyResources(sources, target);
//			} else
				operation.copyResources(sources, target);
		}

		return problems;
	}
 
Example 19
Source File: RenameResourceAndCloseEditorAction.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
protected IRunnableWithProgress createOperation(final IStatus[] errorStatus) {
	return new IRunnableWithProgress() {
		public void run(IProgressMonitor monitor) {
			IResource[] resources = (IResource[]) getActionResources()
					.toArray(new IResource[getActionResources().size()]);
			// Rename is only valid for a single resource. This has already
			// been validated.
			if (resources.length == 1) {
				// check for overwrite
				IWorkspaceRoot workspaceRoot = resources[0].getWorkspace()
						.getRoot();
				IResource newResource = workspaceRoot.findMember(newPath);
				boolean go = true;
				if (newResource != null) {
					go = checkOverwrite(shellProvider.getShell(), newResource);
				}
				if (go) {
					MoveResourcesOperation op = new MoveResourcesOperation(
							resources[0],
							newPath,
							IDEWorkbenchMessages.RenameResourceAction_operationTitle);
					op.setModelProviderIds(getModelProviderIds());
					try {
						PlatformUI
								.getWorkbench()
								.getOperationSupport()
								.getOperationHistory()
								.execute(
										op,
										monitor,
										WorkspaceUndoUtil
												.getUIInfoAdapter(shellProvider.getShell()));
					} catch (ExecutionException e) {
						if (e.getCause() instanceof CoreException) {
							errorStatus[0] = ((CoreException) e.getCause())
									.getStatus();
						} else {
							errorStatus[0] = new Status(IStatus.ERROR,
									PlatformUI.PLUGIN_ID,
									getProblemsMessage(), e);
						}
					}
				}
			}
		}
	};
}
 
Example 20
Source File: ExportDataSourceDialog.java    From birt with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * 
 * @param severity
 * @param message
 * @return
 */
protected Status getMiscStatus( int severity, String message )
{
	return new Status( severity, PlatformUI.PLUGIN_ID, severity, message, null );
}