本文整理汇总了Java中org.eclipse.ui.handlers.HandlerUtil类的典型用法代码示例。如果您正苦于以下问题:Java HandlerUtil类的具体用法?Java HandlerUtil怎么用?Java HandlerUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HandlerUtil类属于org.eclipse.ui.handlers包,在下文中一共展示了HandlerUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
/*MessageDialog.openInformation(
window.getShell(),
"Plugin",
"Hello, Eclipse world");*/
// Pfad vom Projekt
if (window != null)
{
IStructuredSelection selection = (IStructuredSelection) window.getSelectionService().getSelection();
Object firstElement = selection.getFirstElement();
if (firstElement instanceof IAdaptable)
{
IProject project = (IProject)((IAdaptable)firstElement).getAdapter(IProject.class);
IPath path = project.getFullPath();
System.out.println("Projekt: "+path);
StartEGL.start(""+path);
}
}
return null;
}
示例2: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event);
IWorkbenchWindow[] windows = N4IDEXpectUIPlugin.getDefault().getWorkbench().getWorkbenchWindows();
try {
view = (N4IDEXpectView) windows[0].getActivePage().showView(
N4IDEXpectView.ID);
} catch (PartInitException e) {
N4IDEXpectUIPlugin.logError("cannot refresh test view window", e);
}
Description desc = (Description) selection.getFirstElement();
if (desc.isTest() && view.testsExecutionStatus.hasFailed(desc)) {
Throwable failureException = view.testsExecutionStatus.getFailure(desc).getException();
if (failureException instanceof ComparisonFailure) {
ComparisonFailure cf = (ComparisonFailure) failureException;
// display comparison view
displayComparisonView(cf, desc);
}
}
return null;
}
示例3: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入依赖的package包/类
@Override
public final Object execute ( final ExecutionEvent event ) throws ExecutionException
{
final IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked ( event );
final Object value = event.getParameter ( PARAMETER_NAME_VIEW_ID );
try
{
final String[] viewIds = ( (String)value ).split ( ":" );
if ( viewIds.length == 1 )
{
openView ( viewIds[0], null, window );
}
else if ( viewIds.length == 2 )
{
openView ( viewIds[0], viewIds[1], window );
}
}
catch ( final PartInitException e )
{
throw new ExecutionException ( "Part could not be initialized", e ); //$NON-NLS-1$
}
return null;
}
示例4: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection sel = HandlerUtil.getCurrentSelection(event);
if (sel.isEmpty())
return null;
if (!(sel instanceof IStructuredSelection))
return null;
Object obj = ((IStructuredSelection) sel).getFirstElement();
if (!(obj instanceof IFile))
return null;
try {
ConvertToFileCreationWizard wizard = new ConvertToFileCreationWizard( );
wizard.init(PlatformUI.getWorkbench(), (IStructuredSelection)sel);
Shell activeShell = HandlerUtil.getActiveShell(event);
if (activeShell==null) return null;
WizardDialog dialog = new WizardDialog(activeShell,wizard);
dialog.open();
} catch (Exception e) {
ResourceManager.logException(e);
}
return null;
}
示例5: getProject
import org.eclipse.ui.handlers.HandlerUtil; //导入依赖的package包/类
static PgDbProject getProject(ExecutionEvent event){
try{
ISelection sel = HandlerUtil.getActiveMenuSelection(event);
IStructuredSelection selection = (IStructuredSelection) sel;
if (selection == null){
return null;
}
Object firstElement = selection.getFirstElement();
if (firstElement instanceof IProject) {
IProject proj = (IProject)firstElement;
if (proj.getNature(NATURE.ID) != null) {
return new PgDbProject(proj);
}
}
} catch (CoreException ce){
Log.log(Log.LOG_ERROR, ce.getMessage());
}
return null;
}
示例6: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) {
IWorkbenchPart part = HandlerUtil.getActiveEditor(event);
if (part instanceof SQLEditor){
SQLEditor sqlEditor = (SQLEditor) part;
if (sqlEditor.getCurrentDb() != null) {
sqlEditor.updateDdl();
} else {
MessageBox mb = new MessageBox(HandlerUtil.getActiveShell(event), SWT.ICON_INFORMATION);
mb.setText(Messages.UpdateDdl_select_source);
mb.setMessage(Messages.UpdateDdl_select_source_msg);
mb.open();
}
}
return null;
}
示例7: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入依赖的package包/类
/**
* the command has been executed, so extract extract the needed information
* from the application context.
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil
.getActiveWorkbenchWindowChecked(event);
final Display display = Display.getDefault();
final Shell shell = window.getShell();
Locale.setDefault(Locale.ENGLISH);
final TipDayEx tipDayEx = new TipDayEx();
for (String tipMessage : new String[] { "This is the first tip",
"This is the second tip", "This is the third tip",
"This is the forth tip", "This is the fifth tip" }) {
tipDayEx.addTip(String.format(
"<h4>%s</h4>" + "<b>%s</b> " + "<u>%s</u> " + "<i>%s</i> " + "%s "
+ "%s<br/>" + "<p color=\"#A00000\">%s</p>",
tipMessage, tipMessage, tipMessage, tipMessage, tipMessage,
tipMessage, tipMessage));
}
tipDayEx.open(shell, display);
return null;
}
示例8: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入依赖的package包/类
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final IWorkbenchWindow activeWorkbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
final ISourceProviderService service =
activeWorkbenchWindow.getService(ISourceProviderService.class);
final AnalysisSourceProvider sourceProvider =
(AnalysisSourceProvider) service.getSourceProvider(AnalysisSourceProvider.ANALYSIS_STATE);
sourceProvider.setPassive();
final Thread thread = new Thread(new Runnable() {
@Override
public void run() {
AlloyValidator.isCanceled = true;
AlloyOtherSolutionReasoning.getInstance().finish();
AlloyOtherSolutionDiscovering.getInstance().finish();
AlloyOtherSolutionReasoningForAtom.getInstance().finish();
Visualization.showViz();
}
});
thread.start();
return true;
}
示例9: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入依赖的package包/类
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final IWorkbenchWindow activeWorkbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
final ISourceProviderService service =
activeWorkbenchWindow.getService(ISourceProviderService.class);
final AnalysisSourceProvider sourceProvider =
(AnalysisSourceProvider) service.getSourceProvider(AnalysisSourceProvider.ANALYSIS_STATE);
final Thread thread = new Thread(new Runnable() {
@Override
public void run() {
if (sourceProvider.getEvaluationState() == EvaluationState.OPEN) {
Visualization.evaluatorOpen = false;
sourceProvider.setEvaluationState(EvaluationState.CLOSE);
} else if (sourceProvider.getEvaluationState() == EvaluationState.CLOSE) {
Visualization.evaluatorOpen = true;
sourceProvider.setEvaluationState(EvaluationState.OPEN);
}
Visualization.showViz();
}
});
thread.start();
return true;
}
示例10: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入依赖的package包/类
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final IWorkbenchWindow activeWorkbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
final ISourceProviderService service =
activeWorkbenchWindow.getService(ISourceProviderService.class);
final AnalysisSourceProvider sourceProvider =
(AnalysisSourceProvider) service.getSourceProvider(AnalysisSourceProvider.ANALYSIS_STATE);
sourceProvider.setActive(ReasoningType.DISCOVER_RELATION);
final Thread thread = new Thread(new Runnable() {
@Override
public void run() {
final AlloyReasoning alloyReasoning = new AlloyReasoning();
final boolean reasoning = alloyReasoning.reasoning();
if (!reasoning) {
sourceProvider.setPassive();
}
Visualization.showViz();
}
});
thread.start();
return true;
}
示例11: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入依赖的package包/类
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final IWorkbenchWindow activeWorkbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
final ISourceProviderService service =
activeWorkbenchWindow.getService(ISourceProviderService.class);
final AnalysisSourceProvider sourceProvider =
(AnalysisSourceProvider) service.getSourceProvider(AnalysisSourceProvider.ANALYSIS_STATE);
sourceProvider.setActive(ReasoningType.DISCOVER_ATOM);
final Thread thread = new Thread(new Runnable() {
@Override
public void run() {
final AlloyDiscovering alloyDiscovering = new AlloyDiscovering();
final boolean discovering =
alloyDiscovering.discovering();
if (!discovering) {
Visualization.sourceProvider.setPassive();
}
Visualization.showViz();
}
});
thread.start();
return true;
}
示例12: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入依赖的package包/类
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final IEditorPart editorPart = HandlerUtil.getActiveEditor(event);
final ICompilationUnit icu = JavaUI.getWorkingCopyManager().getWorkingCopy(editorPart.getEditorInput());
try {
final IType type = icu.getTypes()[0];
final List<Field> fields = new ArrayList<>();
for (final IField field : type.getFields()) {
final String fieldName = field.getElementName();
final String fieldType = Signature.getSignatureSimpleName(field.getTypeSignature());
fields.add(new Field(fieldName, fieldType));
}
new WizardDialog(HandlerUtil.getActiveShell(event), new BuilderGeneratorWizard(icu, fields)).open();
}
catch (final JavaModelException e) {
e.printStackTrace();
}
return null;
}
示例13: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
TreeSelection selection = (TreeSelection) HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
Object firstElement = selection.getFirstElement();
if (firstElement instanceof IAdaptable)
{
IFile file = (IFile)((IAdaptable)firstElement).getAdapter(IFile.class);
IPath path = file.getLocation();
try {
//TODO fix
SurveyGenerator.generateAll(path.toOSString(), path.toOSString());
MessageDialog.openInformation(shell, "Success", "Code was generated successfully");
} catch (Exception e) {
//MessageDialog.openError(shell, "Error", e.getMessage());
e.printStackTrace();
}
}
return null;
}
示例14: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final IPath containerPath = new Path(Initializer.APGAS_CONTAINER_ID);
try {
final IJavaProject javaProject = JavaCore
.create(((IAdaptable) ((IStructuredSelection) HandlerUtil
.getCurrentSelection(event)).getFirstElement())
.getAdapter(IProject.class));
final IClasspathEntry[] entries = javaProject.getRawClasspath();
for (int i = 0; i < entries.length; i++) {
if (entries[i].getEntryKind() == IClasspathEntry.CPE_CONTAINER
&& entries[i].getPath().equals(containerPath)) {
return null;
}
}
final IClasspathEntry[] cp = new IClasspathEntry[entries.length + 1];
System.arraycopy(entries, 0, cp, 0, entries.length);
cp[entries.length] = JavaCore.newContainerEntry(containerPath);
javaProject.setRawClasspath(cp, new NullProgressMonitor());
} catch (final Exception e) {
throw new ExecutionException(e.toString(), e);
}
return null;
}
示例15: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
markSpec = getMark();
IEditorPart edPart = HandlerUtil.getActiveEditor(event);
if (edPart instanceof FluentMkEditor) {
editor = (FluentMkEditor) edPart;
doc = editor.getDocument();
if (doc != null) {
ISelection sel = HandlerUtil.getCurrentSelection(event);
if (sel instanceof TextSelection) {
TextSelection tsel = (TextSelection) sel;
int beg = tsel.getOffset();
int len = tsel.getLength();
cpos = editor.getCursorOffset();
if (len == 0) beg = cpos;
try {
if (samePartition(beg, len)) {
toggle(beg, len);
}
} catch (BadLocationException e) {}
}
}
}
return null;
}