org.eclipse.ui.internal.ide.IDEWorkbenchMessages Java Examples

The following examples show how to use org.eclipse.ui.internal.ide.IDEWorkbenchMessages. 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: DeleteResourceAndCloseEditorAction.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Asks the user to confirm a delete operation, where the selection contains no projects.
 * @param resources
 *            the selected resources
 * @return <code>true</code> if the user says to go ahead, and <code>false</code> if the deletion should be
 *         abandoned
 */
private boolean confirmDeleteNonProjects(IResource[] resources) {
	String title;
	String msg;
	if (resources.length == 1) {
		title = IDEWorkbenchMessages.DeleteResourceAction_title1;
		IResource resource = resources[0];
		if (resource.isLinked()) {
			msg = NLS.bind(IDEWorkbenchMessages.DeleteResourceAction_confirmLinkedResource1, resource.getName());
		} else {
			msg = NLS.bind(IDEWorkbenchMessages.DeleteResourceAction_confirm1, resource.getName());
		}
	} else {
		title = IDEWorkbenchMessages.DeleteResourceAction_titleN;
		if (containsLinkedResource(resources)) {
			msg = NLS.bind(IDEWorkbenchMessages.DeleteResourceAction_confirmLinkedResourceN, new Integer(
					resources.length));
		} else {
			msg = NLS.bind(IDEWorkbenchMessages.DeleteResourceAction_confirmN, new Integer(resources.length));
		}
	}
	return MessageDialog.openQuestion(shellProvider.getShell(), title, msg);
}
 
Example #2
Source File: DeleteResourceAndCloseEditorAction.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Asks the user to confirm a delete operation, where the selection contains no projects.
 * @param resources
 *            the selected resources
 * @return <code>true</code> if the user says to go ahead, and <code>false</code> if the deletion should be
 *         abandoned
 */
private boolean confirmDeleteNonProjects(IResource[] resources) {
	String title;
	String msg;
	if (resources.length == 1) {
		title = IDEWorkbenchMessages.DeleteResourceAction_title1;
		IResource resource = resources[0];
		if (resource.isLinked()) {
			msg = NLS.bind(IDEWorkbenchMessages.DeleteResourceAction_confirmLinkedResource1, resource.getName());
		} else {
			msg = NLS.bind(IDEWorkbenchMessages.DeleteResourceAction_confirm1, resource.getName());
		}
	} else {
		title = IDEWorkbenchMessages.DeleteResourceAction_titleN;
		if (containsLinkedResource(resources)) {
			msg = NLS.bind(IDEWorkbenchMessages.DeleteResourceAction_confirmLinkedResourceN, new Integer(
					resources.length));
		} else {
			msg = NLS.bind(IDEWorkbenchMessages.DeleteResourceAction_confirmN, new Integer(resources.length));
		}
	}
	return MessageDialog.openQuestion(shellProvider.getShell(), title, msg);
}
 
Example #3
Source File: ExitDialog.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected static String exitMessage() {
    String productName = null;
    final IProduct product = Platform.getProduct();
    if (product != null) {
        productName = product.getName();
    }
    String message = null;
    if (productName == null) {
        message = IDEWorkbenchMessages.PromptOnExitDialog_message0;
    } else {
        message = NLS.bind(
                IDEWorkbenchMessages.PromptOnExitDialog_message1,
                productName);
    }
    return message;
}
 
Example #4
Source File: CopyFilesAndFoldersOperation.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Validates the copy or move operation.
 *
 * @param resources
 *            the resources being copied or moved
 * @param destinationPath
 *            the destination of the copy or move
 * @return whether the operation should proceed
 * @since 3.2
 */
private boolean validateOperation(IResource[] resources, IPath destinationPath) {
    IResourceChangeDescriptionFactory factory = ResourceChangeValidator.getValidator().createDeltaFactory();
    for (int i = 0; i < resources.length; i++) {
        IResource resource = resources[i];
        if (isMove()) {
            factory.move(resource, destinationPath.append(resource.getName()));
        } else {
            factory.copy(resource, destinationPath.append(resource.getName()));
        }
    }
    String title;
    String message;
    if (isMove()) {
        title = IDEWorkbenchMessages.CopyFilesAndFoldersOperation_confirmMove;
        message = IDEWorkbenchMessages.CopyFilesAndFoldersOperation_warningMove;
    } else {
        title = IDEWorkbenchMessages.CopyFilesAndFoldersOperation_confirmCopy;
        message = IDEWorkbenchMessages.CopyFilesAndFoldersOperation_warningCopy;
    }
    return IDE
            .promptToConfirm(messageShell, title, message, factory.getDelta(), modelProviderIds,
                    true /* syncExec */);
}
 
Example #5
Source File: DeleteResourceAction.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Tries to find opened editors matching given resource roots. The editors will be closed without confirmation and
 * only if the editor resource does not exists anymore.
 *
 * @param resourceRoots
 *            non null array with deleted resource tree roots
 * @param deletedOnly
 *            true to close only editors on resources which do not exist
 */
static void closeMatchingEditors(final List<? extends IResource> resourceRoots, final boolean deletedOnly) {
	if (resourceRoots.isEmpty()) { return; }
	final Runnable runnable = () -> SafeRunner.run(new SafeRunnable(IDEWorkbenchMessages.ErrorOnCloseEditors) {
		@Override
		public void run() {
			final IWorkbenchWindow w = WorkbenchHelper.getWindow();
			if (w != null) {
				final List<IEditorReference> toClose = getMatchingEditors(resourceRoots, w, deletedOnly);
				if (toClose.isEmpty()) { return; }
				closeEditors(toClose, w);
			}
		}
	});
	BusyIndicator.showWhile(PlatformUI.getWorkbench().getDisplay(), runnable);
}
 
Example #6
Source File: NewUZProjectWizardPage.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
protected boolean validatePage() {
  	canFinish=false;	
  	   getShell().setText(Messages.CREATEPROJECTWIZARD);
      IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace();

      String projectFieldContents = getProjectNameFieldValue();
      if (projectFieldContents.equals("")) {
          setErrorMessage(null);
          setMessage(IDEWorkbenchMessages.WizardNewProjectCreationPage_projectNameEmpty);
          return false;
      }

      IStatus nameStatus = workspace.validateName(projectFieldContents,
              IResource.PROJECT);
      if (!nameStatus.isOK()) {
          setErrorMessage(nameStatus.getMessage());
          return false;
      }
     
      IProject handle = getProjectHandle();
      if (handle.exists()) {
          setErrorMessage(IDEWorkbenchMessages.WizardNewProjectCreationPage_projectExistsMessage);
          return false;
      }
return dialogChanged();
  }
 
Example #7
Source File: OpenFileAction.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Opens an editor on the given file resource.
 *
 * @param file
 *            the file resource
 */
void privateOpenFile(final IFile file) {
	try {
		final boolean activate = OpenStrategy.activateOnOpen();
		if (editorDescriptor == null) {
			IDE.openEditor(WorkbenchHelper.getPage(), file, activate);
		} else {
			if (ensureFileLocal(file)) {
				WorkbenchHelper.getPage().openEditor(new FileEditorInput(file), editorDescriptor.getId(), activate);
			}
		}
	} catch (final PartInitException e) {
		DialogUtil.openError(WorkbenchHelper.getPage().getWorkbenchWindow().getShell(),
				IDEWorkbenchMessages.OpenFileAction_openFileShellTitle, e.getMessage(), e);
	}
}
 
Example #8
Source File: CloseResourceAction.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Tries to find opened editors matching given resource roots. The editors will be closed without confirmation and
 * only if the editor resource does not exists anymore.
 *
 * @param resourceRoots
 *            non null array with deleted resource tree roots
 * @param deletedOnly
 *            true to close only editors on resources which do not exist
 */
static void closeMatchingEditors(final List<? extends IResource> resourceRoots, final boolean deletedOnly) {
	if (resourceRoots.isEmpty()) { return; }
	final Runnable runnable = () -> SafeRunner.run(new SafeRunnable(IDEWorkbenchMessages.ErrorOnCloseEditors) {
		@Override
		public void run() {
			final IWorkbenchWindow w = getActiveWindow();
			if (w != null) {
				final List<IEditorReference> toClose = getMatchingEditors(resourceRoots, w, deletedOnly);
				if (toClose.isEmpty()) { return; }
				closeEditors(toClose, w);
			}
		}
	});
	BusyIndicator.showWhile(PlatformUI.getWorkbench().getDisplay(), runnable);
}
 
Example #9
Source File: RefreshHandler.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
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 #10
Source File: GamaActionBarAdvisor.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates and returns the Edit menu.
 */
private MenuManager createEditMenu() {
	final MenuManager menu = new MenuManager(IDEWorkbenchMessages.Workbench_edit, IWorkbenchActionConstants.M_EDIT);
	menu.add(new GroupMarker(IWorkbenchActionConstants.EDIT_START));
	menu.add(undoAction);
	menu.add(redoAction);
	menu.add(new GroupMarker(IWorkbenchActionConstants.UNDO_EXT));
	menu.add(new Separator());
	menu.add(getCutItem());
	menu.add(getCopyItem());
	menu.add(getPasteItem());
	menu.add(new GroupMarker(IWorkbenchActionConstants.CUT_EXT));
	menu.add(new Separator());
	menu.add(getDeleteItem());
	menu.add(getSelectAllItem());
	menu.add(new Separator());
	menu.add(getFindItem());
	menu.add(new GroupMarker(IWorkbenchActionConstants.FIND_EXT));
	menu.add(new Separator());
	menu.add(new GroupMarker(IWorkbenchActionConstants.ADD_EXT));
	menu.add(new GroupMarker(IWorkbenchActionConstants.EDIT_END));
	menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
	return menu;
}
 
Example #11
Source File: ImportTraceWizardPage.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected void createDestinationGroup(Composite parent) {
    Composite containerComposite = new Composite(parent, SWT.NONE);
    containerComposite.setLayout(new GridLayout(2, false));
    containerComposite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));

    Label destinationLabel = new Label(containerComposite, SWT.NONE);
    destinationLabel.setText(IDEWorkbenchMessages.WizardImportPage_folder);

    Text containerText = new Text(containerComposite, SWT.SINGLE);
    containerText.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
    containerText.setEnabled(false);

    // Initialize the field with the container path
    containerText.setText(getContainerFullPath().toString());
}
 
Example #12
Source File: ExitDialog.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public static MessageDialogWithToggle openExitDialog(final Shell parentShell) {
    MessageDialogWithToggle dialog = null;
    if (deleteTenantOnExit()) {
        dialog = new ExitDialog(parentShell, IDEWorkbenchMessages.PromptOnExitDialog_shellTitle, null, null, WARNING, new String[] {
                IDialogConstants.OK_LABEL,
                IDialogConstants.CANCEL_LABEL },
                0, IDEWorkbenchMessages.PromptOnExitDialog_choice, false);
        dialog.open();
    } else {
        dialog = MessageDialogWithToggle
                .openOkCancelConfirm(parentShell,
                        IDEWorkbenchMessages.PromptOnExitDialog_shellTitle,
                        exitMessage(),
                        IDEWorkbenchMessages.PromptOnExitDialog_choice,
                        false, null, null);
    }
    return dialog;
}
 
Example #13
Source File: GamaActionBarAdvisor.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates and returns the Help menu.
 */
private MenuManager createHelpMenu() {
	final MenuManager menu = new MenuManager(IDEWorkbenchMessages.Workbench_help, IWorkbenchActionConstants.M_HELP);
	addSeparatorOrGroupMarker(menu, "group.intro"); //$NON-NLS-1$
	menu.add(new GroupMarker("group.intro.ext")); //$NON-NLS-1$
	addSeparatorOrGroupMarker(menu, "group.main"); //$NON-NLS-1$
	menu.add(helpContentsAction);
	addSeparatorOrGroupMarker(menu, "group.assist"); //$NON-NLS-1$
	menu.add(new GroupMarker(IWorkbenchActionConstants.HELP_START));
	menu.add(new GroupMarker("group.main.ext")); //$NON-NLS-1$
	addSeparatorOrGroupMarker(menu, "group.tutorials"); //$NON-NLS-1$
	addSeparatorOrGroupMarker(menu, "group.tools"); //$NON-NLS-1$
	addSeparatorOrGroupMarker(menu, "group.updates"); //$NON-NLS-1$
	menu.add(new GroupMarker(IWorkbenchActionConstants.HELP_END));
	addSeparatorOrGroupMarker(menu, IWorkbenchActionConstants.MB_ADDITIONS);
	// about should always be at the bottom
	menu.add(new Separator("group.about")); //$NON-NLS-1$

	final ActionContributionItem aboutItem = new ActionContributionItem(aboutAction);
	aboutItem.setVisible(!Util.isMac());
	menu.add(aboutItem);
	menu.add(new GroupMarker("group.about.ext")); //$NON-NLS-1$
	menu.add(openPreferencesAction);
	return menu;
}
 
Example #14
Source File: DeleteResourceAndCloseEditorAction.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new delete resource action.
 * @param provider
 *            the shell provider to use. Must not be <code>null</code>.
 * @since 3.4
 */
public DeleteResourceAndCloseEditorAction(IShellProvider provider) {
	super(IDEWorkbenchMessages.DeleteResourceAction_text);
	Assert.isNotNull(provider);
	initAction();
	setShellProvider(provider);
}
 
Example #15
Source File: InternalFileDialog.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
@Override
	protected Control createDialogArea(Composite parent) {

		Composite topLevel = new Composite(parent, SWT.NONE);
		topLevel.setLayout(new GridLayout());
		topLevel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL
				| GridData.HORIZONTAL_ALIGN_FILL));
		topLevel.setFont(parent.getFont());

		resourceGroup = new ResourceAndContainerGroup(topLevel, this,
				"File name:",
				IDEWorkbenchMessages.WizardNewFileCreationPage_file, false,
				250);
		resourceGroup.setResourceExtension(fileExtension);
		resourceGroup.setContainerFullPath(new Path(initialFolder).removeLastSegments(1));

		if (new Path(initialFolder).lastSegment() != null) {
			resourceGroup.setResource(new Path(initialFolder).lastSegment());
			resourceGroup.setFocus();
		}

		setTitle("File");

//		Text text = new Text(parent, SWT.NONE);
//		text.setText("abc");
		// TODO Auto-generated method stub
		return super.createDialogArea(parent);
	}
 
Example #16
Source File: DeleteResourceAndCloseEditorAction.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new delete resource action.
 * @param provider
 *            the shell provider to use. Must not be <code>null</code>.
 * @since 3.4
 */
public DeleteResourceAndCloseEditorAction(IShellProvider provider) {
	super(IDEWorkbenchMessages.DeleteResourceAction_text);
	Assert.isNotNull(provider);
	initAction();
	setShellProvider(provider);
}
 
Example #17
Source File: DeleteResourceAndCloseEditorAction.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
static String getMessage(IResource[] projects) {
	if (projects.length == 1) {
		IProject project = (IProject) projects[0];
		return NLS.bind(IDEWorkbenchMessages.DeleteResourceAction_confirmProject1, project.getName());
	}
	return NLS.bind(IDEWorkbenchMessages.DeleteResourceAction_confirmProjectN, new Integer(projects.length));
}
 
Example #18
Source File: CopyFilesAndFoldersOperation.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Checks whether the destination is valid for copying the source file
 * stores.
 * <p>
 * Note this method is for internal use only. It is not API.
 * </p>
 * <p>
 * TODO Bug 117804. This method has been renamed to avoid a bug in the
 * Eclipse compiler with regards to visibility and type resolution when
 * linking.
 * </p>
 *
 * @param destination
 *            the destination container
 * @param sourceStores
 *            the source IFileStore
 * @return an error message, or <code>null</code> if the path is valid
 */
private String validateImportDestinationInternal(IContainer destination, IFileStore[] sourceStores) {
    if (!isAccessible(destination)) {
        return IDEWorkbenchMessages.CopyFilesAndFoldersOperation_destinationAccessError;
    }

    IFileStore destinationStore;
    try {
        destinationStore = EFS.getStore(destination.getLocationURI());
    } catch (CoreException exception) {
        IDEWorkbenchPlugin.log(exception.getLocalizedMessage(), exception);
        return NLS.bind(IDEWorkbenchMessages.CopyFilesAndFoldersOperation_internalError,
                exception.getLocalizedMessage());
    }
    for (int i = 0; i < sourceStores.length; i++) {
        IFileStore sourceStore = sourceStores[i];
        IFileStore sourceParentStore = sourceStore.getParent();

        if (sourceStore != null) {
            if (destinationStore.equals(sourceStore)
                    || (sourceParentStore != null && destinationStore.equals(sourceParentStore))) {
                return NLS.bind(IDEWorkbenchMessages.CopyFilesAndFoldersOperation_importSameSourceAndDest,
                        sourceStore.getName());
            }
            // work around bug 16202. replacement for
            // sourcePath.isPrefixOf(destinationPath)
            IFileStore destinationParent = destinationStore.getParent();
            if (sourceStore.isParentOf(destinationParent)) {
                return IDEWorkbenchMessages.CopyFilesAndFoldersOperation_destinationDescendentError;
            }

        }
    }
    return null;
}
 
Example #19
Source File: RenameResourceAndCloseEditorAction.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the new name to be given to the target resource.
 * 
 * @return java.lang.String
 * @param resource
 *            the resource to query status on
 */
protected String queryNewResourceName(final IResource resource) {
	final IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace();
	final IPath prefix = resource.getFullPath().removeLastSegments(1);
	IInputValidator validator = new IInputValidator() {
		public String isValid(String string) {
			if (resource.getName().equals(string)) {
				return IDEWorkbenchMessages.RenameResourceAction_nameMustBeDifferent;
			}
			IStatus status = workspace.validateName(string, resource
					.getType());
			if (!status.isOK()) {
				return status.getMessage();
			}
			if (workspace.getRoot().exists(prefix.append(string))) {
				return IDEWorkbenchMessages.RenameResourceAction_nameExists;
			}
			return null;
		}
	};

	InputDialog dialog = new InputDialog(shellProvider.getShell(),
			IDEWorkbenchMessages.RenameResourceAction_inputDialogTitle,
			IDEWorkbenchMessages.RenameResourceAction_inputDialogMessage,
			resource.getName(), validator);
	dialog.setBlockOnOpen(true);
	int result = dialog.open();
	if (result == Window.OK)
		return dialog.getValue();
	return null;
}
 
Example #20
Source File: DeleteResourceAndCloseEditorAction.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
protected Control createCustomArea(Composite parent) {
	Composite composite = new Composite(parent, SWT.NONE);
	composite.setLayout(new GridLayout());
	String text1;
	if (projects.length == 1) {
		IProject project = (IProject) projects[0];
		if (project == null || project.getLocation() == null) {
			text1 = IDEWorkbenchMessages.DeleteResourceAction_deleteContentsN;
		} else {
			text1 = NLS.bind(IDEWorkbenchMessages.DeleteResourceAction_deleteContents1, project.getLocation()
					.toOSString());
		}
	} else {
		text1 = IDEWorkbenchMessages.DeleteResourceAction_deleteContentsN;
	}
	
	Label tipLbl = new Label(composite, SWT.NONE);
	tipLbl.setFont(parent.getFont());
	tipLbl.setText(text1);
	deleteContent = true;

	Label detailsLabel = new Label(composite, SWT.LEFT);
	detailsLabel.setText(IDEWorkbenchMessages.DeleteResourceAction_deleteContentsDetails);
	detailsLabel.setFont(parent.getFont());
	// indent the explanatory label
	GridData data = new GridData();
	data.horizontalIndent = IDialogConstants.INDENT;
	detailsLabel.setLayoutData(data);
	// add a listener so that clicking on the label selects the
	// corresponding radio button.
	// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=172574
	// Add a spacer label
	new Label(composite, SWT.LEFT);

	


	return composite;
}
 
Example #21
Source File: OpenFileWithValidAction.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new action that will open instances of the specified editor on the then-selected file resources.
 * @param page
 *            the workbench page in which to open the editor
 * @param descriptor
 *            the editor descriptor, or <code>null</code> if unspecified
 */
public OpenFileWithValidAction(IWorkbenchPage page, IEditorDescriptor descriptor) {
	super(page);
	setText(descriptor == null ? IDEWorkbenchMessages.OpenFileAction_text : descriptor.getLabel());
	PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IIDEHelpContextIds.OPEN_FILE_ACTION);
	setToolTipText(IDEWorkbenchMessages.OpenFileAction_toolTip);
	setId(ID);
	this.editorDescriptor = descriptor;
}
 
Example #22
Source File: WizardFolderImportPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * The <code>WizardDataTransfer</code> implementation of this <code>IOverwriteQuery</code> method asks the user
 * whether the existing resource at the given path should be overwritten.
 * 
 * @param pathString
 * @return the user's reply: one of <code>"YES"</code>, <code>"NO"</code>, <code>"ALL"</code>, or
 *         <code>"CANCEL"</code>
 */
public String queryOverwrite(String pathString)
{

	Path path = new Path(pathString);

	String messageString;
	// Break the message up if there is a file name and a directory
	// and there are at least 2 segments.
	if (path.getFileExtension() == null || path.segmentCount() < 2)
	{
		messageString = NLS.bind(IDEWorkbenchMessages.WizardDataTransfer_existsQuestion, pathString);
	}

	else
	{
		messageString = NLS.bind(IDEWorkbenchMessages.WizardDataTransfer_overwriteNameAndPathQuestion,
				path.lastSegment(), path.removeLastSegments(1).toOSString());
	}

	final MessageDialog dialog = new MessageDialog(getContainer().getShell(), IDEWorkbenchMessages.Question, null,
			messageString, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL,
					IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL,
					IDialogConstants.CANCEL_LABEL }, 0);
	String[] response = new String[] { YES, ALL, NO, NO_ALL, CANCEL };
	// run in syncExec because callback is from an operation,
	// which is probably not running in the UI thread.
	getControl().getDisplay().syncExec(new Runnable()
	{
		public void run()
		{
			dialog.open();
		}
	});
	return dialog.getReturnCode() < 0 ? CANCEL : response[dialog.getReturnCode()];
}
 
Example #23
Source File: DeleteResourceAndCloseEditorAction.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
protected Control createCustomArea(Composite parent) {
	Composite composite = new Composite(parent, SWT.NONE);
	composite.setLayout(new GridLayout());
	String text1;
	if (projects.length == 1) {
		IProject project = (IProject) projects[0];
		if (project == null || project.getLocation() == null) {
			text1 = IDEWorkbenchMessages.DeleteResourceAction_deleteContentsN;
		} else {
			text1 = NLS.bind(IDEWorkbenchMessages.DeleteResourceAction_deleteContents1, project.getLocation()
					.toOSString());
		}
	} else {
		text1 = IDEWorkbenchMessages.DeleteResourceAction_deleteContentsN;
	}
	
	Label tipLbl = new Label(composite, SWT.NONE);
	tipLbl.setFont(parent.getFont());
	tipLbl.setText(text1);
	deleteContent = true;

	Label detailsLabel = new Label(composite, SWT.LEFT);
	detailsLabel.setText(IDEWorkbenchMessages.DeleteResourceAction_deleteContentsDetails);
	detailsLabel.setFont(parent.getFont());
	// indent the explanatory label
	GridData data = new GridData();
	data.horizontalIndent = IDialogConstants.INDENT;
	detailsLabel.setLayoutData(data);
	// add a listener so that clicking on the label selects the
	// corresponding radio button.
	// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=172574
	// Add a spacer label
	new Label(composite, SWT.LEFT);

	


	return composite;
}
 
Example #24
Source File: RenameResourceAndCloseEditorAction.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the new name to be given to the target resource.
 * 
 * @return java.lang.String
 * @param resource
 *            the resource to query status on
 */
protected String queryNewResourceName(final IResource resource) {
	final IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace();
	final IPath prefix = resource.getFullPath().removeLastSegments(1);
	IInputValidator validator = new IInputValidator() {
		public String isValid(String string) {
			if (resource.getName().equals(string)) {
				return IDEWorkbenchMessages.RenameResourceAction_nameMustBeDifferent;
			}
			IStatus status = workspace.validateName(string, resource
					.getType());
			if (!status.isOK()) {
				return status.getMessage();
			}
			if (workspace.getRoot().exists(prefix.append(string))) {
				return IDEWorkbenchMessages.RenameResourceAction_nameExists;
			}
			return null;
		}
	};

	InputDialog dialog = new InputDialog(shellProvider.getShell(),
			IDEWorkbenchMessages.RenameResourceAction_inputDialogTitle,
			IDEWorkbenchMessages.RenameResourceAction_inputDialogMessage,
			resource.getName(), validator);
	dialog.setBlockOnOpen(true);
	int result = dialog.open();
	if (result == Window.OK)
		return dialog.getValue();
	return null;
}
 
Example #25
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 #26
Source File: WizardNewProjectCreationPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
   * Creates the project name specification controls.
   *
   * @param parent the parent composite
   */
  private final void createProjectNameGroup(Composite parent) {
      // project specification group
      Composite projectGroup = new Composite(parent, SWT.NONE);
      GridLayout layout = new GridLayout();
      layout.numColumns = 2;
      projectGroup.setLayout(layout);
      projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

      // new project label
      Label projectLabel = new Label(projectGroup, SWT.NONE);
      projectLabel.setText(IDEWorkbenchMessages.WizardNewProjectCreationPage_nameLabel);
      projectLabel.setFont(parent.getFont());

      // new project name entry field
      projectNameField = new Text(projectGroup, SWT.BORDER);
      GridData data = new GridData(GridData.FILL_HORIZONTAL);
      data.widthHint = SIZING_TEXT_FIELD_WIDTH;
      projectNameField.setLayoutData(data);
      projectNameField.setFont(parent.getFont());

      // Set the initial value first before listener
      // to avoid handling an event during the creation.
      if (initialProjectFieldValue != null) {
	projectNameField.setText(initialProjectFieldValue);
}
      projectNameField.addListener(SWT.Modify, nameModifyListener);
  }
 
Example #27
Source File: OpenFileWithValidAction.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new action that will open instances of the specified editor on the then-selected file resources.
 * @param page
 *            the workbench page in which to open the editor
 * @param descriptor
 *            the editor descriptor, or <code>null</code> if unspecified
 */
public OpenFileWithValidAction(IWorkbenchPage page, IEditorDescriptor descriptor) {
	super(page);
	setText(descriptor == null ? IDEWorkbenchMessages.OpenFileAction_text : descriptor.getLabel());
	PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IIDEHelpContextIds.OPEN_FILE_ACTION);
	setToolTipText(IDEWorkbenchMessages.OpenFileAction_toolTip);
	setId(ID);
	this.editorDescriptor = descriptor;
}
 
Example #28
Source File: WizardNewProjectCreationPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
   * Returns whether this page's controls currently all contain valid 
   * values.
   *
   * @return <code>true</code> if all controls are valid, and
   *   <code>false</code> if at least one is invalid
   */
  protected boolean validatePage() {
      IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace();

      String projectFieldContents = getProjectNameFieldValue();
      if (projectFieldContents.equals("")) { //$NON-NLS-1$
          setErrorMessage(null);
          setMessage(IDEWorkbenchMessages.WizardNewProjectCreationPage_projectNameEmpty);
          return false;
      }

      IStatus nameStatus = workspace.validateName(projectFieldContents,
              IResource.PROJECT);
      if (!nameStatus.isOK()) {
          setErrorMessage(nameStatus.getMessage());
          return false;
      }

      IProject handle = getProjectHandle();
      if (handle.exists()) {
          setErrorMessage(IDEWorkbenchMessages.WizardNewProjectCreationPage_projectExistsMessage);
          return false;
      }
              
      IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
		getProjectNameFieldValue());
locationArea.setExistingProject(project);

String validLocationMessage = locationArea.checkValidLocation();
if (validLocationMessage != null) { // there is no destination location given
	setErrorMessage(validLocationMessage);
	return false;
}

      setErrorMessage(null);
      setMessage(null);
      return true;
  }
 
Example #29
Source File: DeleteResourceAndCloseEditorAction.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Action initialization.
 */
private void initAction() {
	setToolTipText(IDEWorkbenchMessages.DeleteResourceAction_toolTip);
	PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IIDEHelpContextIds.DELETE_RESOURCE_ACTION);
	setId(ID);
}
 
Example #30
Source File: CopyFilesAndFoldersOperation.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Returns a new name for a copy of the resource at the given path in the
 * given workspace.
 *
 * @param originalName
 *            the full path of the resource
 * @param workspace
 *            the workspace
 * @return the new full path for the copy, or <code>null</code> if the
 *         resource should not be copied
 */
private IPath getNewNameFor(final IPath originalName, final IWorkspace workspace) {
    final IResource resource = workspace.getRoot().findMember(originalName);
    final IPath prefix = resource.getFullPath().removeLastSegments(1);
    final String returnValue[] = { "" }; //$NON-NLS-1$

    messageShell.getDisplay().syncExec(new Runnable() {
        @Override
        public void run() {
            IInputValidator validator = new IInputValidator() {
                @Override
                public String isValid(String string) {
                    if (resource.getName().equals(string)) {
                        return IDEWorkbenchMessages.CopyFilesAndFoldersOperation_nameMustBeDifferent;
                    }
                    IStatus status = workspace.validateName(string, resource.getType());
                    if (!status.isOK()) {
                        return status.getMessage();
                    }
                    if (workspace.getRoot().exists(prefix.append(string))) {
                        return IDEWorkbenchMessages.CopyFilesAndFoldersOperation_nameExists;
                    }
                    return null;
                }
            };

            InputDialog dialog = new InputDialog(messageShell,
                    IDEWorkbenchMessages.CopyFilesAndFoldersOperation_inputDialogTitle, NLS.bind(
                            IDEWorkbenchMessages.CopyFilesAndFoldersOperation_inputDialogMessage,
                            resource.getName()),
                    getAutoNewNameFor(originalName, workspace).lastSegment()
                            .toString(),
                    validator);
            dialog.setBlockOnOpen(true);
            dialog.open();
            if (dialog.getReturnCode() == Window.CANCEL) {
                returnValue[0] = null;
            } else {
                returnValue[0] = dialog.getValue();
            }
        }
    });
    if (returnValue[0] == null) {
        throw new OperationCanceledException();
    }
    return prefix.append(returnValue[0]);
}