org.eclipse.e4.core.di.annotations.Execute Java Examples

The following examples show how to use org.eclipse.e4.core.di.annotations.Execute. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SwitchToBufferFrameCmd.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
@Execute
public Object execute(@Active MWindow window, @Active MPart apart, @Active IEditorPart editor, @Active EmacsPlusCmdHandler handler, @Named(E4CmdHandler.CMD_CTX_KEY)boolean display, @Named(E4CmdHandler.PRE_CTX_KEY) String prefix) {
	this.window = window;
	this.handler = handler;
	this.apart = apart;
	this.displayOnly = display;
	this.prefix = prefix;
	try {
		ITextEditor ted = EmacsPlusUtils.getTextEditor(editor, true);
		if (ted != null) {
			MinibufferHandler.bufferTransform(new SwitchMinibuffer(this, true), ted, null);
		}
	} catch (BadLocationException e) {
		// Shouldn't happen
		Beeper.beep();
	}		
	return null;
}
 
Example #2
Source File: SwitchToBufferOtherCmd.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
@Execute
public Object execute(@Active MPart apart, @Active IEditorPart editor, @Active EmacsPlusCmdHandler handler, @Named(E4CmdHandler.CMD_CTX_KEY)boolean display, @Named(E4CmdHandler.PRE_CTX_KEY) String prefix) {
	this.handler = handler;
	this.apart = apart;
	this.displayOnly = display;
	this.prefix = prefix;
	try {
		ITextEditor ted = EmacsPlusUtils.getTextEditor(editor, true);
		if (ted != null) {
			MinibufferHandler.bufferTransform(new SwitchMinibuffer(this), ted, null);
		}
	} catch (BadLocationException e) {
		// Shouldn't happen
		Beeper.beep();
	}		
	return null;
}
 
Example #3
Source File: ToolbarProcessor.java    From MergeProcessor with Apache License 2.0 6 votes vote down vote up
@Execute
public void execute(IConfiguration configuration) {
	for (final MToolBarElement element : toolbar.getChildren()) {
		if (element instanceof MToolItem) {
			switch (element.getElementId()) {
			case TOOL_ITEM_AUTOMMATIC:
				((MToolItem) element).setSelected(configuration.isAutomatic());
				break;
			case TOOL_ITEM_DISPLAY_DONE:
				((MToolItem) element).setSelected(configuration.isDisplayDone());
				break;
			case TOOL_ITEM_DISPLAY_IGNORED:
				((MToolItem) element).setSelected(configuration.isDisplayIgnored());
				break;
			default:
				break;
			}
		}
	}
}
 
Example #4
Source File: CreateAccountHandler.java    From offspring with MIT License 6 votes vote down vote up
@Execute
public void execute(Display display, IWallet wallet, INxtService nxt,
    IUserService userService, UISynchronize sync) {

  AddAccountDialog dialog = new AddAccountDialog(display.getActiveShell(),
      wallet, nxt);
  if (dialog.open() == Window.OK) {
    try {
      boolean select = userService.getActiveUser() == null;
      for (IWalletAccount walletAccount : wallet.getAccounts()) {
        if (walletAccount instanceof INXTWalletAccount) {
          userService.createUser(walletAccount.getLabel(),
              ((INXTWalletAccount) walletAccount).getPrivateKey(),
              ((INXTWalletAccount) walletAccount).getAccountNumber());
        }
      }
      if (select && userService.getUsers().size() > 0)
        userService.setActiveUser(userService.getUsers().get(0));
    }
    catch (WalletNotInitializedException e) {
      logger.error("Wallet not initialized", e);
    }
  }
}
 
Example #5
Source File: StartJettyHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 6 votes vote down vote up
@Execute
public void execute()  throws Exception{
	Runnable runnable = new Runnable() {
		@Override
		public void run() {
			Server server = new Server(8080);
	        try {
	            server.getConnectors()[0].getConnectionFactory(HttpConnectionFactory.class);
	            server.setHandler(new HelloHttpRequestHandler());

	            server.start();
	            server.join();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	};
	new Thread(runnable).start();
	
	
}
 
Example #6
Source File: OtherWindowCmd.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
@Execute
protected void doOtherWindow(@Active MPart apart, @Named(E4CmdHandler.CMD_CTX_KEY)String cmd, @Active EmacsPlusCmdHandler handler) {
	PartAndStack ps = getParentStack(apart); 
	MElementContainer<MUIElement> otherStack = getAdjacentElement(ps.getStack(), ps.getPart(), true);
	MPart other = (MPart)otherStack.getSelectedElement();
	// TODO An egregious hack that may break at any time
	// Is there a defined way of getting the IEditorPart from an MPart?
	if (other.getObject() instanceof CompatibilityEditor) {
		IEditorPart editor = ((CompatibilityEditor) other.getObject()).getEditor();
		try {
			reactivate(other);
			if (handler.isUniversalPresent()) {
				EmacsPlusUtils.executeCommand(cmd, handler.getUniversalCount(), null, editor);
			} else {
				EmacsPlusUtils.executeCommand(cmd, null, editor);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		finally {
			reactivate(apart);
		}
	}
}
 
Example #7
Source File: AuthTokenHandler.java    From offspring with MIT License 5 votes vote down vote up
@Execute
public void execute(Shell shell, IUserService userService, INxtService nxt,
    UISynchronize sync) {
  AuthTokenDialog dialog = new AuthTokenDialog(shell, nxt, userService);
  dialog.create();
  dialog.setBlockOnOpen(true);
  if (dialog.open() == Window.OK) {

  }
}
 
Example #8
Source File: QuitHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Execute
public void execute(IWorkbench workbench, Shell shell){
	if (MessageDialog.openConfirm(shell, "Confirmation",
			"Do you want to exit?")) {
		workbench.close();
	}
}
 
Example #9
Source File: QuitHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Execute
public void execute(IWorkbench workbench, Shell shell){
	if (MessageDialog.openConfirm(shell, "Confirmation",
			"Do you want to exit?")) {
		workbench.close();
	}
}
 
Example #10
Source File: WindowShrinkCmd.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
@Execute
public Object execute(@Active MPart apart,  @Named(E4CmdHandler.CMD_CTX_KEY)Col stype, @Active EmacsPlusCmdHandler handler) {
	PartAndStack ps = getParentStack(apart);
	MElementContainer<MUIElement> stack = ps.getStack();
	MElementContainer<MUIElement> next = getAdjacentElement(stack, ps.getPart(), false);
	
	int count = handler.getUniversalCount();
	// if we have an adjacent part, we're in a sash
	if (next != null) {
		switch (stype) {
		case SHRINK:
			adjustContainerData((MUIElement)stack, (MUIElement)next, count, getTotalSize(apart));
			break;
		case ENLARGE:
			adjustContainerData((MUIElement)next, (MUIElement)stack, count, getTotalSize(apart));
			break;
		case BALANCE:
			balancePartSash(stack);
			break;
		}
		// For some reason, in recent eclipses, we have to request the layout manually
           Object widget = stack.getWidget();
           // Double check before grabbing the parent composite for looping 
		if (widget instanceof CTabFolder) {
			// this is apparently the recommended way of getting these to redraw properly
			for (Control c : ((Composite)widget).getParent().getChildren()) {
				c.requestLayout();
			}
		}
	}	
	return null;
}
 
Example #11
Source File: LookupBlockHandler.java    From offspring with MIT License 5 votes vote down vote up
@Execute
public void execute(INxtService nxt, IStylingEngine engine,
    IUserService userService, UISynchronize sync) {

  InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(),
      "Lookup Block", "Enter block id", "", new BlockValidator());
  if (dialog.open() == Window.OK) {
    Long id = Convert.parseUnsignedLong(dialog.getValue());
    InspectBlockDialog.show(id, nxt, engine, userService, sync,
        ContactsService.getInstance());
  }
}
 
Example #12
Source File: SavePerspectiveHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Execute
public void execute(EModelService modelService, MWindow window) {

	// clone the currently active perspective
	MPerspective activePerspective = modelService
			.getActivePerspective(window);
	modelService.cloneElement(activePerspective, window);
}
 
Example #13
Source File: DeleteBlocksHandler.java    From offspring with MIT License 5 votes vote down vote up
@Execute
public void execute(Shell shell) {
  if (MessageDialog
      .openConfirm(
          shell,
          "Reset Blockchain",
          "Are you sure you want to reset the blockchain?\nOffspring will re-download the blockchain for you.")) {
    Nxt.getBlockchainProcessor().fullReset();
  }
}
 
Example #14
Source File: LookupAccountHandler.java    From offspring with MIT License 5 votes vote down vote up
@Execute
public void execute(INxtService nxt, IStylingEngine engine,
    IUserService userService, UISynchronize sync) {

  InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(),
      "Lookup Account", "Enter account number", "", new AccountValidator());
  if (dialog.open() == Window.OK) {
    Long id = Convert.parseUnsignedLong(dialog.getValue());
    InspectAccountDialog.show(id, nxt, engine, userService, sync,
        ContactsService.getInstance());
  }
}
 
Example #15
Source File: ShowTraderPerspectiveHandler.java    From offspring with MIT License 5 votes vote down vote up
@Execute
public void execute(MApplication app, EPartService partService,
    EModelService modelService) {
  MPerspective element = (MPerspective) modelService.find(PART_ID, app);
  partService.switchPerspective(element);
  logger.trace("Switch to " + PART_ID);
}
 
Example #16
Source File: UpdateHandler.java    From offspring with MIT License 5 votes vote down vote up
@Execute
public void execute(Display display, Shell shell, UISynchronize sync,
    IProvisioningAgent agent, INxtService nxt, IDataProviderPool pool,
    IWorkbench workbench) {

  UpdateDialog dialog = new UpdateDialog(display, shell, sync, agent, pool,
      workbench);
  dialog.create();
  dialog.open();
}
 
Example #17
Source File: WindowDeclOtherCmd.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
@Execute
public Object execute(@Active MPart apart, @Active IEditorPart editor, @Active MWindow mwin, @Active EmacsPlusCmdHandler handler) {

	try {
		this.apart = apart;
		this.handler = handler;
		Command ex = getOpenCmd(editor);
		if (ex != null) {
			MUIElement area = getEditArea(application.getChildren().get(0));
			MUIElement osel = getSelected(area);
			EmacsPlusUtils.executeCommand(ex.getId(), null);
			MUIElement sel = getSelected(area);
			// see if it was able to open a declaration
			if (sel instanceof MPart && sel != apart && sel != osel) {
				// another way of determining if we're main or frame
				if (!mwin.getTags().contains(TOP_TAG) && !handler.isUniversalPresent()) {
					// If they're in different frames, move copy to source frame first
					modelService.move(sel, getParentStack(apart).getStack(), 0);
				};
				switchTo((MPart)sel);
			}
		}
	} catch (Exception e) {
		// Shouldn't happen
		Beeper.beep();
	}
	return null;
}
 
Example #18
Source File: E4CmdHandler.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	extractUniversalCount(event);	// initialize uArg
	// Pass the non-e4 handler so it can be injected into the command if necessary
	IEclipseContext ctx = EclipseContextFactory.create();
	addToContext(ctx);
	return ContextInjectionFactory.invoke(e4cmd, Execute.class, getContext(), ctx, null);
}
 
Example #19
Source File: QuitHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Execute
public void execute(IWorkbench workbench, Shell shell){
	if (MessageDialog.openConfirm(shell, "Confirmation",
			"Do you want to exit?")) {
		workbench.close();
	}
}
 
Example #20
Source File: SwitchPerspectiveHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Execute
public void execute(EModelService modelService, EPartService partService,
		MWindow window,
		@Named("com.vogella.rcp.jface.translation.commandparameter.perspectiveid") String id) {
	MPerspective activePerspective = modelService
			.getActivePerspective(window);


	MUIElement find = modelService.find(id, window);
	if (find == null || activePerspective.equals(find)) {
		return;
	}

	partService.switchPerspective((MPerspective) find);
}
 
Example #21
Source File: RestorePerspectiveHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Execute
public void execute(EModelService modelService, MWindow window, EPartService partService) {

	// get active perpective and find stored snippet of this perspective
	MPerspective activePerspective = modelService.getActivePerspective(window);
	MUIElement perspectiveSnippet = modelService.cloneSnippet(window, activePerspective.getElementId(), window);

	// remove existing active perspective
	MElementContainer<MUIElement> parent = activePerspective.getParent();
	modelService.removePerspectiveModel(activePerspective, window);

	// add stored perspective snippet and switch to it
	parent.getChildren().add(perspectiveSnippet);
	partService.switchPerspective((MPerspective) perspectiveSnippet);
}
 
Example #22
Source File: QuitHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Execute
public void execute(IWorkbench workbench, Shell shell){
	if (MessageDialog.openConfirm(shell, "Confirmation",
			"Do you want to exit?")) {
		workbench.close();
	}
}
 
Example #23
Source File: QuitHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Execute
public void execute(IWorkbench workbench, Shell shell){
	if (MessageDialog.openConfirm(shell, "Confirmation",
			"Do you want to exit?")) {
		workbench.close();
	}
}
 
Example #24
Source File: QuitHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Execute
public void execute(IWorkbench workbench, Shell shell){
	if (MessageDialog.openConfirm(shell, "Confirmation",
			"Do you want to exit?")) {
		workbench.close();
	}
}
 
Example #25
Source File: QuitHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Execute
public void execute(IWorkbench workbench, Shell shell){
	if (MessageDialog.openConfirm(shell, "Confirmation",
			"Do you want to exit?")) {
		workbench.close();
	}
}
 
Example #26
Source File: QuitHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Execute
public void execute(IWorkbench workbench, Shell shell){
	if (MessageDialog.openConfirm(shell, "Confirmation",
			"Do you want to exit?")) {
		workbench.close();
	}
}
 
Example #27
Source File: AddMarkerHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Execute
public void execute(@Named(IServiceConstants.ACTIVE_SELECTION) IStructuredSelection selection, Adapter adapter) {

	if (selection == null || selection.isEmpty()) {
		return;
	}

	Object firstElement = selection.getFirstElement();
	IResource resource = adapter.adapt(firstElement, IResource.class);

	if (resource != null) {
		writeMarkers(resource);
	}

}
 
Example #28
Source File: QuitHandler.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Execute
public void execute(IWorkbench workbench, Shell shell){
	if (MessageDialog.openConfirm(shell, "Confirmation",
			"Do you want to exit?")) {
		workbench.close();
	}
}
 
Example #29
Source File: DemoWidgetsProcessor.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * This operation executes the instructions required to register the demo
 * widgets with the e4 workbench.
 * 
 * @param context
 *            The e4 context
 * @param app
 *            the model application
 */
@Execute
public void execute(IEclipseContext context, MApplication app) {

	// Add the geometry provider
	IPageProvider provider = ContextInjectionFactory
			.make(DemoGeometryPageProvider.class, context);
	context.set("demo-geometry", provider);

	// Add the EntryComposite provider
	IEntryCompositeProvider compProvider = ContextInjectionFactory
			.make(DemoEntryCompositeProvider.class, context);
	context.set("demo-entry", compProvider);

}
 
Example #30
Source File: WindowSplitCmd.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
@Execute
public Object execute(@Active MPart apart, @Active IEditorPart editor, @Named(E4CmdHandler.CMD_CTX_KEY)int cmd, 
		@Active EmacsPlusCmdHandler handler) {
	if (handler.isUniversalPresent()) {
		// convenience hack
		// change setting without changing preference store
		setSplitSelf(!isSplitSelf());
	}
	split(apart, editor, cmd);
	return null;
}