java.util.Vector#removeAll ( )源码实例Demo

下面列出了java.util.Vector#removeAll ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: gemfirexd-oss   文件: ParticipantGmsImpl.java
/**
     * Determines whether this member is the new coordinator given a list of suspected members.  This is
     * computed as follows: the list of currently suspected members (suspected_mbrs) is removed from the current
     * membership. If the first member of the resulting list is equals to the local_addr, then it is true,
     * otherwise false. Example: own address is B, current membership is {A, B, C, D}, suspected members are {A,
     * D}. The resulting list is {B, C}. The first member of {B, C} is B, which is equal to the
     * local_addr. Therefore, true is returned.
     * @param suspects members that have crashed
     * @param departures members that have departed normally
     */
    boolean wouldIBeCoordinator(Vector suspects, Set<Address> departures) {
        Address new_coord;
        Vector mbrs=gms.members.getMembers(); // getMembers() returns a *copy* of the membership vector

        if (log.isDebugEnabled()) {
          log.debug("wouldIBeCoordinator:\nmembers = " + mbrs + "\ndeparted = " + this.departed_mbrs
              + "\nsuspected = " + this.suspected_mbrs);
        }

        if (suspects != null) {
          mbrs.removeAll(suspects);
        }
        
        if (departures != null) {
          mbrs.removeAll(departures);
        }

        if(mbrs.size() < 1) return false;
        // GemStoneAddition - revised for split-brain detection
        new_coord = new Membership(mbrs).getCoordinator();
//        log.getLogWriterI18n().info(JGroupsStrings.DEBUG, "pgms: of members " + mbrs + " the coordinator would be " + new_coord);
        if (new_coord == null) { // oops - no eligable coordinators
          return false;
        }
        return gms.local_addr.equals(new_coord);
    }
 
源代码2 项目: tlaplus   文件: TraceExplorerComposite.java
/**
 * Remove the selected formulas
 */
protected void doRemove()
{
    final IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
    final Vector<?> input = (Vector<?>)tableViewer.getInput();
    
    input.removeAll(selection.toList());
    tableViewer.setInput(input);

    changeButtonEnablement();

    saveModel();
}
 
源代码3 项目: tlaplus   文件: ValidateableTableSectionPart.java
/**
 * Remove the selected formulas
 */
protected void doRemove()
{
    IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
    Vector input = (Vector) tableViewer.getInput();
    input.removeAll(selection.toList());
    tableViewer.setInput(input);
    this.doMakeDirty();
}
 
源代码4 项目: gemfirexd-oss   文件: ParticipantGmsImpl.java
/**
     * Determines whether this member is the new coordinator given a list of suspected members.  This is
     * computed as follows: the list of currently suspected members (suspected_mbrs) is removed from the current
     * membership. If the first member of the resulting list is equals to the local_addr, then it is true,
     * otherwise false. Example: own address is B, current membership is {A, B, C, D}, suspected members are {A,
     * D}. The resulting list is {B, C}. The first member of {B, C} is B, which is equal to the
     * local_addr. Therefore, true is returned.
     * @param suspects members that have crashed
     * @param departures members that have departed normally
     */
    boolean wouldIBeCoordinator(Vector suspects, Set<Address> departures) {
        Address new_coord;
        Vector mbrs=gms.members.getMembers(); // getMembers() returns a *copy* of the membership vector

        if (log.isDebugEnabled()) {
          log.debug("wouldIBeCoordinator:\nmembers = " + mbrs + "\ndeparted = " + this.departed_mbrs
              + "\nsuspected = " + this.suspected_mbrs);
        }

        if (suspects != null) {
          mbrs.removeAll(suspects);
        }
        
        if (departures != null) {
          mbrs.removeAll(departures);
        }

        if(mbrs.size() < 1) return false;
        // GemStoneAddition - revised for split-brain detection
        new_coord = new Membership(mbrs).getCoordinator();
//        log.getLogWriterI18n().info(JGroupsStrings.DEBUG, "pgms: of members " + mbrs + " the coordinator would be " + new_coord);
        if (new_coord == null) { // oops - no eligable coordinators
          return false;
        }
        return gms.local_addr.equals(new_coord);
    }
 
源代码5 项目: tlaplus   文件: ModelHelper.java
/**
 * This method eventually changes the constants list. If the signature constants of both
 * lists are equal, the constants list is left untouched. Otherwise, all constants not present
 * in the constantsFromModule are removed, and all missing are added.
 * <br>
 * For constant comparison {@link Assignment#equalSignature(Assignment)} is used
 * 
 * @param constants the list with constants, eventually the subject of change
 * @param constantsFromModule a list of constants from the module (no right side, no params)
 */
public static List<Assignment> mergeConstantLists(List<Assignment> constants, List<Assignment> constantsFromModule)
{
    Vector<Assignment> constantsToAdd = new Vector<Assignment>();
    Vector<Assignment> constantsUsed = new Vector<Assignment>();
    Vector<Assignment> constantsToDelete = new Vector<Assignment>();

    // iterate over constants from module
    for (int i = 0; i < constantsFromModule.size(); i++)
    {
        Assignment fromModule = (Assignment) constantsFromModule.get(i);
        // find it in the module list
        boolean found = false;

        for (int j = 0; j < constants.size(); j++)
        {
            Assignment constant = constants.get(j);
            if (fromModule.equalSignature(constant))
            {
                // store the information that the constant is used
                constantsUsed.add(constant);
                found = true;
                break;
            }
        }
        // constant is in the module but not in the model
        if (!found)
        {
            // save the constant for adding later
            constantsToAdd.add(fromModule);
        }
    }

    // add all
    constantsToDelete.addAll(constants);
    // remove all used
    constantsToDelete.removeAll(constantsUsed);

    // at this point, all used constants are in the constantUsed list
    constants.retainAll(constantsUsed);

    // all constants to add are in constantsTo Add list
    constants.addAll(constantsToAdd);

    return constantsToDelete;
}
 
源代码6 项目: translationstudio8   文件: MergeXliffHandler.java
public Object execute(ExecutionEvent event) throws ExecutionException {
	IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
	final Shell shell = window.getShell();

	ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
	if (currentSelection != null && !currentSelection.isEmpty() && currentSelection instanceof IStructuredSelection) {

		IStructuredSelection structuredSelection = (IStructuredSelection) currentSelection;

		if (structuredSelection.size() < 2) {
			MessageDialog.openInformation(shell, Messages.getString("handler.MergeXliffHandler.msgTitle1"),
					Messages.getString("handler.MergeXliffHandler.msg1"));
			return null;
		}

		Vector<IFile> seleFiles = new Vector<IFile>();
		String notXlfFile = "";
		@SuppressWarnings("rawtypes")
		Iterator selectIt = structuredSelection.iterator();
		while (selectIt.hasNext()) {
			Object object = selectIt.next();
			if (object instanceof IFile) {
				IFile selectFile = (IFile) object;
				String fileExtension = selectFile.getFileExtension();

				// 如果后缀名不是xlf,那么就进行提示
				if (fileExtension == null || !CommonFunction.validXlfExtension(fileExtension)) {
					notXlfFile += selectFile.getFullPath().toOSString() + ",";
				}
				seleFiles.add(selectFile);
			}
		}

		if (notXlfFile.length() > 0) {
			notXlfFile = notXlfFile.substring(0, notXlfFile.length() - 1);
			boolean isSure = MessageDialog.openConfirm(shell, Messages
					.getString("handler.MergeXliffHandler.msgTitle2"), MessageFormat.format(
					Messages.getString("handler.MergeXliffHandler.msg2"), new Object[] { notXlfFile }));
			if (!isSure) {
				return null;
			}
		}
		
		List<IFile> lstFiles = new ArrayList<IFile>();
		XLFValidator.resetFlag();
		for (IFile iFile : seleFiles) {
			if (!XLFValidator.validateXliffFile(iFile)) {
				lstFiles.add(iFile);
			}
		}
		XLFValidator.resetFlag();
		seleFiles.removeAll(lstFiles);
		if (seleFiles.size() == 0) {
			return null;
		}
		
		if (seleFiles.size() > 0) {
			String projectPath = seleFiles.get(0).getProject().getFullPath().toOSString();
			for (int i = 1; i < seleFiles.size(); i++) {
				if (!projectPath.equals(seleFiles.get(i).getProject().getFullPath().toOSString())) {
					MessageDialog.openInformation(shell, Messages.getString("handler.MergeXliffHandler.msgTitle1"),
							Messages.getString("handler.MergeXliffHandler.msg3"));
					return null;
				}
			}
			SplitOrMergeXlfModel model = new SplitOrMergeXlfModel();
			model.setMergeXliffFile(seleFiles);
			MergeXliffWizard wizard = new MergeXliffWizard(model);
			TSWizardDialog dialog = new NattableWizardDialog(shell, wizard);
			dialog.open();
		}
	}
	return null;
}
 
源代码7 项目: tmxeditor8   文件: MatchViewPart.java
@Override
public void run() {
	while (!stop) {
		// 无新数据到达前进行等待状态
		synchronized (matchDataContainer) {
			if (matchDataContainer.isEmpty()) {
				try {
					matchDataContainer.wait();
				} catch (InterruptedException e) {
				}
			}
		}
		if(matchDataContainer.size() == 0){
			continue;
		}
		// 查找匹配前先清除当前界面中的内容
		Display.getDefault().syncExec(new Runnable() {
			
			public void run() {
				 copyEnable.resetSelection();
				 gridTable.removeAll();
				 altTransCacheList.clear();						
			}
		});				
		MatchData d = matchDataContainer.remove(matchDataContainer.size() - 1);
		this.rowId = d.getRowId();
		this.transUnit = d.getTransUnit();
		this.project = d.getProject();
		// -- execute translation memory match
		manualTranslationThread.interruptCurrentTask();
		manualTranslationThread.setLock(true);
		updateStatusInfo(Messages.getString("view.MatchViewPart.processInfo.loadHSMatch"));
		Vector<AltTransBean> complexMatches = null;
		if (!CommonFunction.checkEdition("L")) {
			Vector<AltTransBean> fuzzy = TmUtils.fuzzyResult2Alttransbean(tmMatcher.executeFuzzySearch(project,
					tuInfoBean));
			transUnit.updateMatches(Constants.TM_TOOLID, fuzzy);
			complexMatches = executeComplexMatch(transUnit, project);
		}
		final Vector<AltTransBean> tmAltTrans = transUnit.getMatchesByToolId(Constants.TM_TOOLID);
		altTransCacheList.addAll(tmAltTrans);
		if (complexMatches != null && complexMatches.size() > 0) {
			altTransCacheList.addAll(complexMatches);
			complexMatches.clear();
			complexMatches = null;
		}
		loadData2UI(altTransCacheList);
		updateStatusInfo(Messages.getString("view.MatchViewPart.processInfo.loadMachineMatch"));
		// 加载Simple Match,如google ,bing
		final List<String> needClearToolId = new ArrayList<String>(); // 需要清掉文件中原有的匹配
		final List<AltTransBean> needSaveAltTransList = new ArrayList<AltTransBean>();
		List<AltTransBean> needLoadAltTransList = new ArrayList<AltTransBean>();
		executeSimpleMatch(tuInfoBean, transUnit, needClearToolId, needSaveAltTransList, needLoadAltTransList);
		loadData2UI(needLoadAltTransList);
		altTransCacheList.addAll(needLoadAltTransList);
		needLoadAltTransList.clear();
		// 加载文件中的其他匹配
		Vector<AltTransBean> cm = new Vector<AltTransBean>();
		if (transUnit.getMatches() != null) {
			cm.addAll(transUnit.getMatches());
			cm.removeAll(altTransCacheList);
			altTransCacheList.addAll(cm);
			if (cm.size() > 0) {
				loadData2UI(cm);
			}
			cm.clear();
		}
		Display.getDefault().syncExec(new Runnable() {

			public void run() {
				updateUI(tmAltTrans);
				setProcessMessage(null, "", "");
			}
		});
		if (needSaveAltTransList.size() > 0 && handler != null) {
			Display.getDefault().syncExec(new Runnable() {

				public void run() {
					// 重新写入altTrans
					handler.updateAltTrans(rowId, needSaveAltTransList, needClearToolId);
					needSaveAltTransList.clear();
					needClearToolId.clear();
				}
			});
		}
		manualTranslationThread.setLock(false);
	}
}
 
源代码8 项目: tmxeditor8   文件: MergeXliffHandler.java
public Object execute(ExecutionEvent event) throws ExecutionException {
	IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
	final Shell shell = window.getShell();

	ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
	if (currentSelection != null && !currentSelection.isEmpty() && currentSelection instanceof IStructuredSelection) {

		IStructuredSelection structuredSelection = (IStructuredSelection) currentSelection;

		if (structuredSelection.size() < 2) {
			MessageDialog.openInformation(shell, Messages.getString("handler.MergeXliffHandler.msgTitle1"),
					Messages.getString("handler.MergeXliffHandler.msg1"));
			return null;
		}

		Vector<IFile> seleFiles = new Vector<IFile>();
		String notXlfFile = "";
		@SuppressWarnings("rawtypes")
		Iterator selectIt = structuredSelection.iterator();
		while (selectIt.hasNext()) {
			Object object = selectIt.next();
			if (object instanceof IFile) {
				IFile selectFile = (IFile) object;
				String fileExtension = selectFile.getFileExtension();

				// 如果后缀名不是xlf,那么就进行提示
				if (fileExtension == null || !CommonFunction.validXlfExtension(fileExtension)) {
					notXlfFile += selectFile.getFullPath().toOSString() + ",";
				}
				seleFiles.add(selectFile);
			}
		}

		if (notXlfFile.length() > 0) {
			notXlfFile = notXlfFile.substring(0, notXlfFile.length() - 1);
			boolean isSure = MessageDialog.openConfirm(shell, Messages
					.getString("handler.MergeXliffHandler.msgTitle2"), MessageFormat.format(
					Messages.getString("handler.MergeXliffHandler.msg2"), new Object[] { notXlfFile }));
			if (!isSure) {
				return null;
			}
		}
		
		List<IFile> lstFiles = new ArrayList<IFile>();
		XLFValidator.resetFlag();
		for (IFile iFile : seleFiles) {
			if (!XLFValidator.validateXliffFile(iFile)) {
				lstFiles.add(iFile);
			}
		}
		XLFValidator.resetFlag();
		seleFiles.removeAll(lstFiles);
		if (seleFiles.size() == 0) {
			return null;
		}
		
		if (seleFiles.size() > 0) {
			String projectPath = seleFiles.get(0).getProject().getFullPath().toOSString();
			for (int i = 1; i < seleFiles.size(); i++) {
				if (!projectPath.equals(seleFiles.get(i).getProject().getFullPath().toOSString())) {
					MessageDialog.openInformation(shell, Messages.getString("handler.MergeXliffHandler.msgTitle1"),
							Messages.getString("handler.MergeXliffHandler.msg3"));
					return null;
				}
			}
			SplitOrMergeXlfModel model = new SplitOrMergeXlfModel();
			model.setMergeXliffFile(seleFiles);
			MergeXliffWizard wizard = new MergeXliffWizard(model);
			TSWizardDialog dialog = new NattableWizardDialog(shell, wizard);
			dialog.open();
		}
	}
	return null;
}