List of usage examples for org.eclipse.jface.dialogs IDialogConstants YES_TO_ALL_ID
int YES_TO_ALL_ID
To view the source code for org.eclipse.jface.dialogs IDialogConstants YES_TO_ALL_ID.
Click Source Link
From source file:org.python.pydev.navigator.actions.copied.CopyFilesAndFoldersOperation.java
License:Open Source License
/** * Returns whether moving all of the given source resources to the given * destination container could be done without causing name collisions. * * @param destination/*from w ww. j a va 2 s. c o m*/ * the destination container * @param sourceResources * the list of resources * @return <code>true</code> if there would be no name collisions, and * <code>false</code> if there would */ private IResource[] validateNoNameCollisions(IContainer destination, IResource[] sourceResources) { List<IResource> copyItems = new ArrayList<IResource>(); IWorkspaceRoot workspaceRoot = destination.getWorkspace().getRoot(); int overwrite = IDialogConstants.NO_ID; // Check to see if we would be overwriting a parent folder. // Cancel entire copy operation if we do. for (int i = 0; i < sourceResources.length; i++) { final IResource sourceResource = sourceResources[i]; final IPath destinationPath = destination.getFullPath().append(sourceResource.getName()); final IPath sourcePath = sourceResource.getFullPath(); IResource newResource = workspaceRoot.findMember(destinationPath); if (newResource != null && destinationPath.isPrefixOf(sourcePath)) { displayError(NLS.bind(IDEWorkbenchMessages.CopyFilesAndFoldersOperation_overwriteProblem, destinationPath, sourcePath)); canceled = true; return null; } } // Check for overwrite conflicts for (int i = 0; i < sourceResources.length; i++) { final IResource source = sourceResources[i]; final IPath destinationPath = destination.getFullPath().append(source.getName()); IResource newResource = workspaceRoot.findMember(destinationPath); if (newResource != null) { if (overwrite != IDialogConstants.YES_TO_ALL_ID || (newResource.getType() == IResource.FOLDER && homogenousResources(source, destination) == false)) { overwrite = checkOverwrite(source, newResource); } if (overwrite == IDialogConstants.YES_ID || overwrite == IDialogConstants.YES_TO_ALL_ID) { copyItems.add(source); } else if (overwrite == IDialogConstants.CANCEL_ID) { canceled = true; return null; } } else { copyItems.add(source); } } return copyItems.toArray(new IResource[copyItems.size()]); }
From source file:org.talend.mdm.repository.ui.wizards.imports.ImportServerObjectWizard.java
License:Open Source License
private int isOveride(String name, String obTypeName) { final MessageDialog dialog = new MessageDialog(getShell(), Messages.Confirm_Overwrite, null, Messages.bind(Messages.Confirm_Overwrite_Info, obTypeName, name), MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0);/*from w w w . java2s . c om*/ dialog.open(); int result = dialog.getReturnCode(); if (result == 0) { return IDialogConstants.YES_ID; } if (result == 1) { return IDialogConstants.YES_TO_ALL_ID; } if (result == 2) { return IDialogConstants.NO_ID; } return IDialogConstants.CANCEL_ID; }
From source file:org.talend.mdm.repository.ui.wizards.imports.ImportServerObjectWizard.java
License:Open Source License
public List<String> doImport(Object[] objs, IProgressMonitor monitor) { monitor.beginTask(Messages.Import_Objects, objs.length); List<String> importedIds = new LinkedList<String>(); ImportService.setImporting(true);//from w w w . ja v a 2 s.com List<Integer> types = new ArrayList<Integer>(); types.add(TreeObject.CUSTOM_FORM); types.add(TreeObject.DATA_CLUSTER); types.add(TreeObject.DATA_MODEL); types.add(TreeObject.TRANSFORMER); types.add(TreeObject.ROUTING_RULE); types.add(TreeObject.MENU); types.add(TreeObject.ROLE); types.add(TreeObject.STORED_PROCEDURE); types.add(TreeObject.VIEW); types.add(TreeObject.WORKFLOW_PROCESS); IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory(); for (Object obj : objs) { try { TreeObject treeObj = (TreeObject) obj; monitor.subTask(treeObj.getDisplayName()); String treeObjName = treeObj.getName(); MDMServerObject eobj = handleSpecialTreeObject(treeObj); if (treeObj.getType() == TreeObject.WORKFLOW_PROCESS) { continue; } if (eobj == null) { if (!types.contains(treeObj.getType()) || treeObj.getWsObject() == null || ("JCAAdapers".equals(treeObj.getName()) //$NON-NLS-1$ && treeObj.getType() == TreeObject.DATA_CLUSTER)) { continue; } eobj = (MDMServerObject) Bean2EObjUtil.getInstance().convertFromBean2EObj(treeObj.getWsObject(), null); } eobj.setLastServerName(serverDef.getName()); ERepositoryObjectType type = RepositoryQueryService.getRepositoryObjectType(treeObj.getType()); String uniqueName = getUniqueName(treeObj, treeObjName); MDMServerObjectItem item = RepositoryQueryService.findServerObjectItemByNameWithDeleted(type, uniqueName, true); if (item != null) { if (!isOverrideAll) { int result = isOveride(treeObj.getName(), TreeObject.getTypeName(treeObj.getType())); if (result == IDialogConstants.CANCEL_ID) { ImportService.setImporting(false); return importedIds; } if (result == IDialogConstants.YES_TO_ALL_ID) { isOverrideAll = true; } if (result == IDialogConstants.NO_ID) { break; } } if (!RepositoryResourceUtil.isLockedItem(item)) { try { factory.lock(item); } catch (PersistenceException e1) { log.error(e1.getMessage(), e1); } catch (LoginException e1) { log.error(e1.getMessage(), e1); } item.setMDMServerObject(eobj); item.getState().setDeleted(false); // save RepositoryResourceUtil.saveItem(item, false); try { factory.unlock(item); } catch (PersistenceException e) { log.error(e.getMessage(), e); } catch (LoginException e) { log.error(e.getMessage(), e); } importedIds.add(item.getProperty().getId()); } CommandManager.getInstance().removeCommandStack(item.getProperty().getId()); } else { IRepositoryNodeConfiguration config = RepositoryNodeConfigurationManager.getConfiguration(type); item = (MDMServerObjectItem) config.getResourceProvider().createNewItem(type); item.setMDMServerObject(eobj); ItemState itemState = PropertiesFactory.eINSTANCE.createItemState(); itemState.setPath(caculatePath(treeObj)); handlePath(itemState, type); item.setState(itemState); String version = getVersion(treeObj); if (RepositoryResourceUtil.createItem(item, uniqueName, version, false, false)) { importedIds.add(item.getProperty().getId()); } } } catch (IOException e) { log.error(e.getMessage(), e); } monitor.worked(1); } ImportService.setImporting(false); monitor.done(); return importedIds; }