當前位置: 首頁>>代碼示例>>Java>>正文


Java SubMonitor.split方法代碼示例

本文整理匯總了Java中org.eclipse.core.runtime.SubMonitor.split方法的典型用法代碼示例。如果您正苦於以下問題:Java SubMonitor.split方法的具體用法?Java SubMonitor.split怎麽用?Java SubMonitor.split使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.core.runtime.SubMonitor的用法示例。


在下文中一共展示了SubMonitor.split方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: rename

import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
/**
 * The gw generated code contains a classname that might be different from the filename chosen in the wizard , which lead to a compile error.
 * We need to fix that by modifying the source code so that names are aligned.
 * @param monitor
 * @return
 */
private void rename(IProgressMonitor monitor)  {
	SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
	 try {
		 String newClassname = getConvertedFile().getName();
		 newClassname  = newClassname.substring(0,newClassname.indexOf("."));
		
		 String oldClassname = context.getSelectedGraphFileName();
		 oldClassname  = oldClassname.substring(0,oldClassname.indexOf("."));
		 subMonitor.split(10);
		 convertedFile =  JDTManager.renameClass(getConvertedFile(), oldClassname, newClassname,monitor);
	} catch (Exception e) {
		ResourceManager.logException(e);
	} finally {
		subMonitor.split(90);
	}
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:23,代碼來源:JavaModelBasedPostConversionImpl.java

示例2: generateOffline

import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
public static void generateOffline(final IResource resource, IPackageFragment pkg, String classfile , BuildPolicy[]  generators, int timeout, IWorkbenchWindow aww) {
	Job job = new Job("GW4E Offline Generation Source Job") {
		@Override
		public IStatus run(IProgressMonitor monitor) {
			try {
				if (resource instanceof IFile) {
					SubMonitor subMonitor = SubMonitor.convert(monitor, 120);
					IFile file = (IFile) resource;
					if (PreferenceManager.isGraphModelFile(file)) {
						AbstractPostConversion converter = getOfflineConversion(file,pkg,classfile,generators,timeout);
						ConversionRunnable runnable = converter.createConversionRunnable(aww);
						subMonitor.subTask("Processing converter ");
						SubMonitor child = subMonitor.split(1);
						runnable.run(child);
					}						
				}
			} catch (Exception e) {
				e.printStackTrace();
				ResourceManager.logException(e);
			}
			return Status.OK_STATUS;
		}
	};
	job.setUser(true);
	job.schedule();
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:27,代碼來源:GraphWalkerContextManager.java

示例3: createFileDeleteIfExists

import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
/**
 * Create a file in a folder with the specified name and content
 * 
 * @param fullpath
 * @param filename
 * @param content
 * @throws CoreException
 * @throws InterruptedException
 */
public static IFile createFileDeleteIfExists(String fullpath, String filename, String content,
		IProgressMonitor monitor) throws CoreException, InterruptedException {
	SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
	subMonitor.setTaskName("Create file delete if it exists " + fullpath);
	IFile newFile;
	try {
		IWorkspaceRoot wroot = ResourcesPlugin.getWorkspace().getRoot();
		IContainer container = (IContainer) wroot.findMember(new Path(fullpath));
		newFile = container.getFile(new Path(filename));
		if (newFile.exists()) {
			JDTManager.rename(newFile, new NullProgressMonitor());
			newFile.delete(true, new NullProgressMonitor());
		}
		subMonitor.split(30);
		byte[] source = content.getBytes(Charset.forName("UTF-8"));
		newFile.create(new ByteArrayInputStream(source), true, new NullProgressMonitor());
		subMonitor.split(70);
	} finally {
		subMonitor.done();
	}
	return newFile;
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:32,代碼來源:ResourceManager.java

示例4: generate

import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
/**
 * @see org.eclipse.tools.templates.freemarker.FMProjectGenerator#generate(java.util.Map,
 *      org.eclipse.core.runtime.IProgressMonitor)
 */
@Override
public void generate(Map<String, Object> model, IProgressMonitor monitor) throws CoreException {
	model.put("statechartName", this.statechartName); //$NON-NLS-1$
	model.put("srcFolder", this.srcFolderName); //$NON-NLS-1$
	model.put("srcGenFolder", this.srcGenFolderName); //$NON-NLS-1$
	model.put("timer", this.timer.getId()); //$NON-NLS-1$
	model.put("cyclePeriod", Integer.toString(this.cyclePeriod)); //$NON-NLS-1$

	final SubMonitor subMonitor = SubMonitor.convert(monitor, 100);

	super.generate(model, subMonitor.split(70));

	final IProject project = getProject();
	CoreModel.getDefault().create(project).setRawPathEntries(
			new IPathEntry[] { CoreModel.newSourceEntry(project.getFullPath()) }, subMonitor.split(10));

	createDiagram(subMonitor.split(20));
}
 
開發者ID:wendehals,項目名稱:arduino_sct_tools,代碼行數:23,代碼來源:ArduinoSCTProjectGenerator.java

示例5: organizeImportsInFile

import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
/** Organize provided file. */
public static void organizeImportsInFile(IFile currentFile, final Interaction interaction, SubMonitor subMon)
		throws CoreException {
	SubMonitor subSubMon = subMon.split(1, SubMonitor.SUPPRESS_NONE);
	subSubMon.setTaskName(currentFile.getName());
	DocumentImportsOrganizer imortsOrganizer = getOrganizeImports(currentFile);
	imortsOrganizer.organizeFile(currentFile, interaction, subSubMon);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:9,代碼來源:OrganizeImportsService.java

示例6: doConversion

import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
/**
 * Perform the conversion by calling GraphWalker apis
 * 
 * @param monitor
 * @return
 * @throws IOException
 * @throws CoreException
 * @throws InterruptedException
 * @throws Exception
 */
protected String doConversion(IProgressMonitor monitor) throws IOException, CoreException, InterruptedException {
	SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
	subMonitor.setTaskName("Converting file...");
	String ret = "";
	try {
		String outputFileName = getSelectedOuputAbsolutePath();
		subMonitor.split(20);
		ret = GraphWalkerFacade.convert(inputFileName, outputFileName);
		subMonitor.split(80);
	} finally {
		subMonitor.done();
	}
	return ret;
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:25,代碼來源:AbstractPostConversion.java

示例7: formatUnitSourceCode

import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
/**
 * Format a Unit Source Code
 * 
 * @param testInterface
 * @param monitor
 * @throws CoreException 
 */
@SuppressWarnings("unchecked")
public static void formatUnitSourceCode(IFile file, IProgressMonitor monitor) throws CoreException {
	@SuppressWarnings("rawtypes")
	SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
	ICompilationUnit unit = JavaCore.createCompilationUnitFrom(file);
	subMonitor.split(50);
	ICompilationUnit workingCopy = unit.getWorkingCopy(monitor);

	Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();

	options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_7);
	options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_7);
	options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_7);

	options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS,
			DefaultCodeFormatterConstants.createAlignmentValue(true,
					DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE,
					DefaultCodeFormatterConstants.INDENT_ON_COLUMN));

	final CodeFormatter codeFormatter = ToolFactory.createCodeFormatter(options);
	ISourceRange range = unit.getSourceRange();
	TextEdit formatEdit = codeFormatter.format(CodeFormatter.K_COMPILATION_UNIT, unit.getSource(),
			range.getOffset(), range.getLength(), 0, null);
	subMonitor.split(30);
	if (formatEdit != null /* && formatEdit.hasChildren()*/) {
		workingCopy.applyTextEdit(formatEdit, monitor);
		workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null);
		workingCopy.commitWorkingCopy(true, null);
		workingCopy.discardWorkingCopy();
	}
	file.refreshLocal(IResource.DEPTH_INFINITE, subMonitor);
	subMonitor.split(20);
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:41,代碼來源:JDTManager.java

示例8: generateInterface

import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
public static void generateInterface(final IResource resource, IWorkbenchWindow aww) {
	Job job = new Job("GW4E Generation Source Job") {
		@Override
		public IStatus run(IProgressMonitor monitor) {
			try {
				if (resource instanceof IFile) {
					SubMonitor subMonitor = SubMonitor.convert(monitor, 120);
					IFile file = (IFile) resource;
					if (PreferenceManager.isGraphModelFile(file)) {
						AbstractPostConversion converter = getDefaultGraphConversion(file, true);
						ConversionRunnable runnable = converter.createConversionRunnable(aww);
						subMonitor.subTask("Processing converter ");
						SubMonitor child = subMonitor.split(1);
						runnable.run(child);
					}						
				} else {
					if (resource instanceof IFolder) {
						generateFromFolder(resource, true, aww);
					}
				}

			} catch (Exception e) {
				e.printStackTrace();
				ResourceManager.logException(e);
			}
			return Status.OK_STATUS;
		}
	};
	job.setUser(true);
	job.schedule();
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:32,代碼來源:GraphWalkerContextManager.java

示例9: performQuery

import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
@Override
public @NonNull IStatus performQuery(@NonNull TaskRepository repository, @NonNull IRepositoryQuery query,
		@NonNull TaskDataCollector collector, @Nullable ISynchronizationSession session,
		@NonNull IProgressMonitor monitor) {

	try {

		List<CharmQueryResult> charmTasks = getClient(repository).queryTasks(monitor, query).getQueryResults();
		SubMonitor subMonitor = SubMonitor.convert(monitor, charmTasks.size());

		for (CharmQueryResult charmTask : charmTasks) {
			TaskData taskData = this.taskDataHandler.parseQueryResults(repository, charmTask, monitor);
			taskData.setPartial(true);
			collector.accept(taskData);
			subMonitor.split(1);
		}

	} catch (CharmException | CoreException e) {
		return new Status(IStatus.ERROR, CharmCorePlugin.PLUGIN_ID, NLS.bind("Query failed: ''{0}''", e.getMessage()),
				e);
	} finally {
		monitor.done();
	}

	return Status.OK_STATUS;

}
 
開發者ID:theits,項目名稱:CharmMylynConnector,代碼行數:28,代碼來源:CharmRepositoryConnector.java

示例10: afterConversion

import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
@Override
public void afterConversion(IProgressMonitor monitor) {
	SubMonitor subMonitor = SubMonitor.convert(monitor, 1);
	subMonitor.split(1);
	subMonitor.done();
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:7,代碼來源:OffLinePostConversionImpl.java

示例11: synchronizeBuildPolicies

import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
/**
 * @param selectedResource
 * @return
 * @throws CoreException
 * @throws InterruptedException
 */
public static void synchronizeBuildPolicies(final IResource selectedResource, IWorkbenchWindow aww)
		throws CoreException, InterruptedException {
	List<ICompilationUnit> executionContexts = new ArrayList<ICompilationUnit>();

	Job job = new WorkspaceJob("GW4E Synchronization Job") {
		@Override
		public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
			try {
				SubMonitor subMonitor = SubMonitor.convert(monitor, 120);
				selectedResource.accept(new IResourceVisitor() {
					@Override
					public boolean visit(IResource resource) throws CoreException {
						if (resource instanceof IFile) {
							IFile file = (IFile) resource;
							if ("java".equals(file.getFileExtension())) {
								ICompilationUnit cu = JavaCore.createCompilationUnitFrom(file);
								if (cu != null) {
									if (JDTManager.isGraphWalkerExecutionContextClass(cu)) {
										executionContexts.add(cu);
									}
								}
							}
						}
						return true;
					}
				});
				subMonitor.split(20);

				int max = executionContexts.size();
				int index = 1;
				subMonitor.setWorkRemaining(max);
				for (ICompilationUnit executionContext : executionContexts) {
					if (monitor.isCanceled())
						return Status.CANCEL_STATUS;
					subMonitor.subTask("Processing file #" + index++);
					SubMonitor child = subMonitor.split(1);
					ResourceManager.updateBuildPolicyFileForCompilatioUnit(executionContext);
				}
			} catch (Exception e) {
				ResourceManager.logException(e);
			}
			return Status.OK_STATUS;
		}
	};
	job.setRule(selectedResource.getProject());
	job.setUser(true);
	job.schedule();
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:55,代碼來源:GraphWalkerContextManager.java

示例12: afterConversion

import org.eclipse.core.runtime.SubMonitor; //導入方法依賴的package包/類
/**
 * Once the source is generated , do whatever you want ... For example :
 * Reformat it ...
 * 
 * @param monitor
 */
public  void afterConversion(IProgressMonitor monitor) {
	SubMonitor subMonitor = SubMonitor.convert(monitor, 1);
	subMonitor.split(1);
	subMonitor.done();
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:12,代碼來源:AbstractPostConversion.java


注:本文中的org.eclipse.core.runtime.SubMonitor.split方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。