当前位置: 首页>>代码示例>>Java>>正文


Java ModalContext类代码示例

本文整理汇总了Java中org.eclipse.jface.operation.ModalContext的典型用法代码示例。如果您正苦于以下问题:Java ModalContext类的具体用法?Java ModalContext怎么用?Java ModalContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ModalContext类属于org.eclipse.jface.operation包,在下文中一共展示了ModalContext类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: open

import org.eclipse.jface.operation.ModalContext; //导入依赖的package包/类
/**
 * If informations are available, opens a <em>System Information</em>
 * dialog, otherwise opens a info message box.
 * 
 * @param shell the parent shell
 * 
 * @see #isAvailable()
 */
public static void open(final Shell shell) {
	try {
		shell.setCursor(shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
		final SystemInformationGatherer gatherer = new SystemInformationGatherer();
		ModalContext.run(gatherer, true, new NullProgressMonitor(), shell.getDisplay());
		if (gatherer.getProperties() != null || gatherer.getEnv() != null || gatherer.getJvmArgs() != null) {
			new SystemInformationDialog(shell, gatherer.getProperties(), gatherer.getEnv(), gatherer.getJvmArgs()).open();
		}
		else {
			final MessageBox box = new MessageBox(shell, SWT.ICON_INFORMATION);
			box.setText(JFaceMessages.get(LBL_SYSTEM_INFO_DIALOG_TITLE));
			box.setMessage(JFaceMessages.get(LBL_SYSTEM_INFO_NOT_AVAILABLE));
			box.open();
		}
	}
	catch (final Exception e) {
		throw new IllegalStateException(e);
	}
	finally {
		shell.setCursor(null);
	}
}
 
开发者ID:Albertus82,项目名称:JFaceUtils,代码行数:31,代码来源:SystemInformationDialog.java

示例2: exportExternalClassFolderElement

import org.eclipse.jface.operation.ModalContext; //导入依赖的package包/类
private void exportExternalClassFolderElement(IJavaElement javaElement, IPath classFolderPath, IProgressMonitor progressMonitor) throws JavaModelException, InterruptedException {
	if (javaElement instanceof IClassFile) {
		IClassFile classFile= (IClassFile) javaElement;
		IPath path= classFile.getPath();

		IPath destination= path.removeFirstSegments(classFolderPath.segmentCount()).setDevice(null);

		try {
			((IJarBuilderExtension) fJarBuilder).writeFile(path.toFile(), destination);
		} catch (CoreException e) {
			handleCoreExceptionOnExport(e);
		} finally {
			progressMonitor.worked(1);
			ModalContext.checkCanceled(progressMonitor);
		}
	} else if (javaElement instanceof IPackageFragment) {
		IJavaElement[] children= ((IPackageFragment) javaElement).getChildren();
		for (int i= 0; i < children.length; i++) {
			exportExternalClassFolderElement(children[i], classFolderPath, progressMonitor);
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:JarFileExportOperation.java

示例3: exportResource

import org.eclipse.jface.operation.ModalContext; //导入依赖的package包/类
private void exportResource(IProgressMonitor progressMonitor, IResource resource, int leadingSegmentsToRemove) throws InterruptedException {
	if (resource instanceof IContainer) {
		IContainer container= (IContainer)resource;
		IResource[] children;
		try {
			children= container.members();
		} catch (CoreException e) {
			// this should never happen because an #isAccessible check is done before #members is invoked
			addWarning(Messages.format(JarPackagerMessages.JarFileExportOperation_errorDuringExport, BasicElementLabels.getPathLabel(container.getFullPath(), false)), e);
			return;
		}
		for (int i= 0; i < children.length; i++)
			exportResource(progressMonitor, children[i], leadingSegmentsToRemove);
	} else if (resource instanceof IFile) {
		try {
			IPath destinationPath= resource.getFullPath().removeFirstSegments(leadingSegmentsToRemove);
			progressMonitor.subTask(Messages.format(JarPackagerMessages.JarFileExportOperation_exporting, BasicElementLabels.getPathLabel(destinationPath, false)));
			fJarBuilder.writeFile((IFile)resource, destinationPath);
		} catch (CoreException ex) {
			handleCoreExceptionOnExport(ex);
		} finally {
			progressMonitor.worked(1);
			ModalContext.checkCanceled(progressMonitor);
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:27,代码来源:JarFileExportOperation.java

示例4: warningGlobalSymbols

import org.eclipse.jface.operation.ModalContext; //导入依赖的package包/类
public static boolean[] warningGlobalSymbols(final String projectName,
		final String objectName, final String objectType,
		final String propertyName, final String propertyValue,
		final Set<String> undefinedSymboles, final boolean showCheckBox) {
	final boolean[] result = {false,false};
	
	getDisplay().syncExec(
		new Runnable() {
			public void run() {
				try {
					int level = ModalContext.getModalLevel();
					if (level > 0) {
						// prevents double modal windows: dead lock on linux/gtk studio
						getDisplay().syncExec(this);
						return;
					} 
					
					GlobalsSymbolsWarnDialog dialogGlobalSymbols = new GlobalsSymbolsWarnDialog(getDisplay().getActiveShell(), projectName,
							objectName, objectType,
							propertyName, propertyValue,
							undefinedSymboles, showCheckBox);
					dialogGlobalSymbols.open();
					
					result[0] = dialogGlobalSymbols.getCreateAction();
					result[1] = dialogGlobalSymbols.getCheckButtonSelection();
				} catch (Exception e){
					ConvertigoPlugin.logException(e, "Error while trying to open warning global symbols box");
				}
			}
		}
	);
	return result;
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:34,代码来源:ConvertigoPlugin.java

示例5: run

import org.eclipse.jface.operation.ModalContext; //导入依赖的package包/类
@Override
public void run(boolean fork, boolean cancelable,
		final IRunnableWithProgress runnable)
		throws InvocationTargetException, InterruptedException {
	ProgressMonitorPart mpart = (ProgressMonitorPart) getProgressMonitor();
	mpart.setVisible(true);
	try {

		ModalContext.run(runnable, fork, getProgressMonitor(), getShell()
				.getDisplay());
	} finally {
		mpart.done();
		mpart.setVisible(false);
	}
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:16,代码来源:FindWizardDialog.java

示例6: run

import org.eclipse.jface.operation.ModalContext; //导入依赖的package包/类
/**
 * This implementation of IRunnableContext#run(boolean, boolean,
 * IRunnableWithProgress) blocks until the runnable has been run, regardless
 * of the value of <code>fork</code>. It is recommended that
 * <code>fork</code> is set to true in most cases. If <code>fork</code>
 * is set to <code>false</code>, the runnable will run in the UI thread
 * and it is the runnable's responsibility to call
 * <code>Display.readAndDispatch()</code> to ensure UI responsiveness.
 * 
 * UI state is saved prior to executing the long-running operation and is
 * restored after the long-running operation completes executing. Any
 * attempt to change the UI state of the wizard in the long-running
 * operation will be nullified when original UI state is restored.
 * 
 */
public void run(boolean fork, boolean cancelable,
		IRunnableWithProgress runnable) throws InvocationTargetException,
		InterruptedException {
	// The operation can only be canceled if it is executed in a separate
	// thread.
	// Otherwise the UI is blocked anyway.
	Object state = null;
	if (activeRunningOperations++ == 0) {
		state = aboutToStart(fork && cancelable);
	}
	try {
		if (!fork) {
			lockedUI = true;
		}
		ModalContext.run(runnable, fork, getProgressMonitor(), getShell()
				.getDisplay());
		lockedUI = false;
	} finally {
		// explicitly invoke done() on our progress monitor so that its
		// label does not spill over to the next invocation, see bug 271530
		if (getProgressMonitor() != null) {
			getProgressMonitor().done();
		}
		// Stop if this is the last one
		if (state != null) {
			timeWhenLastJobFinished= System.currentTimeMillis();
			stopped(state);
		}
		activeRunningOperations--;
	}
}
 
开发者ID:MentorEmbedded,项目名称:p2-installer,代码行数:47,代码来源:WizardDialog.java

示例7: internalRun

import org.eclipse.jface.operation.ModalContext; //导入依赖的package包/类
private void internalRun(boolean fork, final IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException {
	Thread thread= Thread.currentThread();
	// Do not spawn another thread if we are already in a modal context
	// thread or inside a busy context thread.
	if (thread instanceof ThreadContext || ModalContext.isModalContextThread(thread))
		fork= false;

	if (fork) {
		final ThreadContext t= new ThreadContext(runnable);
		t.start();
		t.sync();
		// Check if the separate thread was terminated by an exception
		Throwable throwable= t.fThrowable;
		if (throwable != null) {
			if (throwable instanceof InvocationTargetException) {
				throw (InvocationTargetException) throwable;
			} else if (throwable instanceof InterruptedException) {
				throw (InterruptedException) throwable;
			} else if (throwable instanceof OperationCanceledException) {
				throw new InterruptedException();
			} else {
				throw new InvocationTargetException(throwable);
			}
		}
	} else {
		try {
			runnable.run(new NullProgressMonitor());
		} catch (OperationCanceledException e) {
			throw new InterruptedException();
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:33,代码来源:BusyIndicatorRunnableContext.java

示例8: run

import org.eclipse.jface.operation.ModalContext; //导入依赖的package包/类
/**
 * This implementation of IRunnableContext#run(boolean, boolean,
 * IRunnableWithProgress) blocks until the runnable has been run, regardless
 * of the value of <code>fork</code>. It is recommended that
 * <code>fork</code> is set to true in most cases. If <code>fork</code>
 * is set to <code>false</code>, the runnable will run in the UI thread
 * and it is the runnable's responsibility to call
 * <code>Display.readAndDispatch()</code> to ensure UI responsiveness.
 * 
 * UI state is saved prior to executing the long-running operation and is
 * restored after the long-running operation completes executing. Any
 * attempt to change the UI state of the wizard in the long-running
 * operation will be nullified when original UI state is restored.
 * 
 */
public void run(boolean fork, boolean cancelable,
		IRunnableWithProgress runnable) throws InvocationTargetException,
		InterruptedException {
	// The operation can only be canceled if it is executed in a separate
	// thread.
	// Otherwise the UI is blocked anyway.
	Object state = null;
	if (activeRunningOperations == 0) {
		state = aboutToStart(fork && cancelable);
	}
	activeRunningOperations++;
	try {
		if (!fork) {
			lockedUI = true;
		}
		ModalContext.run(runnable, fork, getProgressMonitor(), getShell()
				.getDisplay());
		lockedUI = false;
	} finally {
		// explicitly invoke done() on our progress monitor so that its
		// label does not spill over to the next invocation, see bug 271530
		if (getProgressMonitor() != null) {
			getProgressMonitor().done();
		}
		// Stop if this is the last one
		if (state != null) {
			timeWhenLastJobFinished= System.currentTimeMillis();
			stopped(state);
		}
		activeRunningOperations--;
	}
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:48,代码来源:TSWizardDialog.java

示例9: run

import org.eclipse.jface.operation.ModalContext; //导入依赖的package包/类
/**
 * 运行线程
 * @param fork
 * @param cancelable
 * @param runnable
 * @throws InvocationTargetException
 * @throws InterruptedException
 *             ;
 */
public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException,
		InterruptedException {
	// The operation can only be canceled if it is executed in a separate
	// thread.
	// Otherwise the UI is blocked anyway.
	Object state = null;
	if (activeRunningOperations == 0) {
		state = aboutToStart(fork && cancelable);
	}
	activeRunningOperations++;
	try {
		if (!fork) {
			lockedUI = true;
		}
		ModalContext.run(runnable, fork, getProgressMonitor(), getShell().getDisplay());
		lockedUI = false;
	} finally {
		// explicitly invoke done() on our progress monitor so that its
		// label does not spill over to the next invocation, see bug 271530
		if (getProgressMonitor() != null) {
			getProgressMonitor().done();
		}
		// Stop if this is the last one
		if (state != null) {
			timeWhenLastJobFinished = System.currentTimeMillis();
			stopped(state);
		}
		activeRunningOperations--;
	}
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:40,代码来源:HsAbstractProgressDialog.java

示例10: startProgress

import org.eclipse.jface.operation.ModalContext; //导入依赖的package包/类
private void startProgress() {
	try {
		Display display = Display.getCurrent();
		SimulationProgress progress = new SimulationProgress(display,
				editor, page);
		ModalContext.run(progress, true, monitor, display);
	} catch (Exception e) {
		log.error("Could not start simulation progress", e);
	}
}
 
开发者ID:GreenDelta,项目名称:olca-app,代码行数:11,代码来源:SimulationControl.java

示例11: run

import org.eclipse.jface.operation.ModalContext; //导入依赖的package包/类
/**
 * This implementation of IRunnableContext#run(boolean, boolean,
 * IRunnableWithProgress) blocks until the runnable has been run, regardless
 * of the value of <code>fork</code>. It is recommended that <code>fork</code>
 * is set to true in most cases. If <code>fork</code> is set to
 * <code>false</code>, the runnable will run in the UI thread and it is the
 * runnable's responsibility to call <code>Display.readAndDispatch()</code> to
 * ensure UI responsiveness.
 * 
 * UI state is saved prior to executing the long-running operation and is
 * restored after the long-running operation completes executing. Any attempt
 * to change the UI state of the wizard in the long-running operation will be
 * nullified when original UI state is restored.
 * 
 */
public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException
{
  // The operation can only be canceled if it is executed in a separate
  // thread.
  // Otherwise the UI is blocked anyway.
  Map<String, Object> state = null;
  if (activeRunningOperations == 0)
  {
    state = aboutToStart(fork && cancelable);
  }
  activeRunningOperations++;
  try
  {
    if (!fork)
    {
      lockedUI = true;
    }
    ModalContext.run(runnable, fork, getProgressMonitor(), getShell().getDisplay());
    lockedUI = false;
  }
  finally
  {
    // explicitly invoke done() on our progress monitor so that its
    // label does not spill over to the next invocation, see bug 271530
    if (getProgressMonitor() != null)
    {
      getProgressMonitor().done();
    }
    // Stop if this is the last one
    if (state != null)
    {
      timeWhenLastJobFinished = System.currentTimeMillis();
      stopped(state);
    }
    activeRunningOperations--;
  }
}
 
开发者ID:terraframe,项目名称:geoprism,代码行数:53,代码来源:LocalizedWizardDialog.java

示例12: runSootDirectly

import org.eclipse.jface.operation.ModalContext; //导入依赖的package包/类
protected void runSootDirectly(String mainClass) {
	
	int length = getSootCommandList().getList().size();
	String temp [] = new String [length];
	
	getSootCommandList().getList().toArray(temp);
	
       String mainProject;
       String realMainClass;
       if(mainClass.contains(":")) {
       	String[] split = mainClass.split(":");
		mainProject = split[0];
       	realMainClass = split[1];
       } else {
       	mainProject = null;
       	realMainClass = mainClass;
       }
	
   	newProcessStarting(realMainClass,mainProject);
       
	sendSootOutputEvent(realMainClass);
	sendSootOutputEvent(" ");
	
	for (int i = 0; i < temp.length; i++) {
		
		sendSootOutputEvent(temp[i]);
		sendSootOutputEvent(" ");
	}
	sendSootOutputEvent("\n");
	
	
	IRunnableWithProgress op; 
	try {   
           op = new SootRunner(temp, Display.getCurrent(), mainClass);
          	((SootRunner)op).setParent(this);
           ModalContext.run(op, true, new NullProgressMonitor(), Display.getCurrent());
		} 
		catch (InvocationTargetException e1) {
   		// handle exception
   		System.out.println("InvocationTargetException: "+e1.getMessage());
   		System.out.println("InvocationTargetException: "+e1.getTargetException());
           System.out.println(e1.getStackTrace());
		} 
		catch (InterruptedException e2) {
   		// handle cancelation
   		System.out.println("InterruptedException: "+e2.getMessage());
		}

}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:50,代码来源:SootLauncher.java

示例13: exportFile

import org.eclipse.jface.operation.ModalContext; //导入依赖的package包/类
/**
 * Export the passed file to the specified location
 *
 * @param file
 *          org.eclipse.core.resources.IFile
 * @param location
 *          org.eclipse.core.runtime.IPath
 */
protected void exportFile(IFile file, IPath location) throws InterruptedException {
  IPath fullPath = location.append(file.getName()).removeFileExtension().addFileExtension("moml");
  monitor.subTask(file.getFullPath().toString());
  String properPathString = fullPath.toOSString();
  File targetFile = new File(properPathString);

  if (targetFile.exists()) {
    if (!targetFile.canWrite()) {
      errorTable.add(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0, NLS.bind("Cannot overwrite file: {0}", targetFile.getAbsolutePath()), null));
      monitor.worked(1);
      return;
    }

    if (overwriteState == OVERWRITE_NONE) {
      return;
    }

    if (overwriteState != OVERWRITE_ALL) {
      String overwriteAnswer = overwriteCallback.queryOverwrite(properPathString);

      if (overwriteAnswer.equals(IOverwriteQuery.CANCEL)) {
        throw new InterruptedException();
      }

      if (overwriteAnswer.equals(IOverwriteQuery.NO)) {
        monitor.worked(1);
        return;
      }

      if (overwriteAnswer.equals(IOverwriteQuery.NO_ALL)) {
        monitor.worked(1);
        overwriteState = OVERWRITE_NONE;
        return;
      }

      if (overwriteAnswer.equals(IOverwriteQuery.ALL)) {
        overwriteState = OVERWRITE_ALL;
      }
    }
  }

  try {
    // 1. obtain Diagram for the file
    Diagram diagram = GraphitiUiInternal.getEmfService().getDiagramFromFile(file, new ResourceSetImpl());
    // 2. find root CompositeActor
    CompositeActor toplevel = (CompositeActor) Graphiti.getLinkService().getBusinessObjectForLinkedPictogramElement(diagram);
    // 3. push location info of diagram model elements to the Ptolemy II model elements
    pushLocations(diagram, toplevel);
    // 4. exportMOML to the destination file
    FileUtils.writeStringToFile(new File(fullPath.toOSString()), toplevel.getWrappedObject().exportMoML());
  } catch (IOException e) {
    errorTable.add(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0, NLS.bind("Error exporting {0}: {1}", fullPath, e.getMessage()), e));
  }

  monitor.worked(1);
  ModalContext.checkCanceled(monitor);
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:66,代码来源:MomlExportOperation.java

示例14: run

import org.eclipse.jface.operation.ModalContext; //导入依赖的package包/类
public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException,
		InterruptedException {
	IProgressMonitor monitor = getProgressMonitor();

	ModalContext.run(runnable, true, monitor, Display.getDefault());
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:7,代码来源:RunWithProgressBar.java


注:本文中的org.eclipse.jface.operation.ModalContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。