Java Code Examples for org.eclipse.e4.ui.di.UISynchronize#syncExec()

The following examples show how to use org.eclipse.e4.ui.di.UISynchronize#syncExec() . 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: HandlerDisplayIgnored.java    From MergeProcessor with Apache License 2.0 5 votes vote down vote up
@Execute
public void execute(MItem item, MPart part, IConfiguration configuration, UISynchronize uiSynch) {
	LogUtil.entering(item, part, configuration, uiSynch);
	configuration.setDisplayIgnored(item.isSelected());
	final Object object = part.getObject();
	if (object instanceof Dashboard) {
		final Dashboard view = (Dashboard) object;
		uiSynch.syncExec(view::refresh);
	}
	LogUtil.exiting();
}
 
Example 2
Source File: HandlerDisplayDone.java    From MergeProcessor with Apache License 2.0 5 votes vote down vote up
@Execute
public void execute(MItem item, MPart part, IConfiguration configuration, UISynchronize uiSynch) {
	LogUtil.entering(item, part, configuration, uiSynch);
	configuration.setDisplayDone(item.isSelected());
	final Object object = part.getObject();
	if (object instanceof Dashboard) {
		final Dashboard view = (Dashboard) object;
		uiSynch.syncExec(view::refresh);
	}
	LogUtil.exiting();
}
 
Example 3
Source File: HandlerRefresh.java    From MergeProcessor with Apache License 2.0 5 votes vote down vote up
@Execute
public void execute(MPart part, UISynchronize uiSynch) {
	LogUtil.entering(part, uiSynch);
	final Object object = part.getObject();
	if (object instanceof Dashboard) {
		final Dashboard view = (Dashboard) object;
		uiSynch.syncExec(view::refresh);
	}
	LogUtil.exiting();
}
 
Example 4
Source File: InspectBlockDialog.java    From offspring with MIT License 5 votes vote down vote up
/**
 * Static method that opens a new dialog or switches the existing dialog to
 * another block id. The dialog shows back and forward buttons to navigate
 * between accounts inspected.
 * 
 * @param blockId
 * @return
 */
public static void show(final Long blockId, final INxtService nxt,
    final IStylingEngine engine, final IUserService userService,
    final UISynchronize sync, final IContactsService contactsService) {
  sync.syncExec(new Runnable() {

    @Override
    public void run() {
      Shell shell = Display.getCurrent().getActiveShell();
      if (shell != null) {
        while (shell.getParent() != null) {
          shell = shell.getParent().getShell();
        }
      }
      if (INSTANCE == null) {
        INSTANCE = new InspectBlockDialog(shell, blockId, nxt, engine,
            userService, sync, contactsService);
        INSTANCE.history.add(blockId);
        INSTANCE.historyCursor = 0;
        INSTANCE.open();
      }
      else {
        INSTANCE.history.add(blockId);
        INSTANCE.historyCursor = INSTANCE.history.size() - 1;
        INSTANCE.setBlockId(blockId);
        INSTANCE.getShell().forceActive();
      }
    }
  });
}
 
Example 5
Source File: InspectAccountDialog.java    From offspring with MIT License 5 votes vote down vote up
/**
 * Static method that opens a new dialog or switches the existing dialog to
 * another account id. The dialog shows back and forward buttons to navigate
 * between accounts inspected.
 * 
 * @param accountId
 * @return
 */
public static void show(final Long accountId, final INxtService nxt,
    final IStylingEngine engine, final IUserService userService,
    final UISynchronize sync, final IContactsService contactsService) {

  sync.syncExec(new Runnable() {

    @Override
    public void run() {
      Shell shell = Display.getCurrent().getActiveShell();
      if (shell != null) {
        while (shell.getParent() != null) {
          shell = shell.getParent().getShell();
        }
      }
      if (INSTANCE == null) {
        INSTANCE = new InspectAccountDialog(shell, accountId, nxt, engine,
            userService, sync, contactsService);
        INSTANCE.history.add(accountId);
        INSTANCE.historyCursor = 0;
        INSTANCE.open();
      }
      else {
        INSTANCE.history.add(accountId);
        INSTANCE.historyCursor = INSTANCE.history.size() - 1;
        INSTANCE.setAccountId(accountId);
        INSTANCE.getShell().forceActive();
      }
    }
  });

}
 
Example 6
Source File: InspectTransactionDialog.java    From offspring with MIT License 5 votes vote down vote up
/**
 * Static method that opens a new dialog or switches the existing dialog to
 * another account id. The dialog shows back and forward buttons to navigate
 * between accounts inspected.
 * 
 * @param transactionId
 * @return
 */
public static void show(final Long transactionId, final INxtService nxt,
    final IStylingEngine engine, final IUserService userService,
    final UISynchronize sync, final IContactsService contactsService) {
  sync.syncExec(new Runnable() {

    @Override
    public void run() {
      Shell shell = Display.getCurrent().getActiveShell();
      if (shell != null) {
        while (shell.getParent() != null) {
          shell = shell.getParent().getShell();
        }
      }
      if (INSTANCE == null) {
        INSTANCE = new InspectTransactionDialog(shell, transactionId, nxt,
            engine, userService, sync, contactsService);
        INSTANCE.history.add(transactionId);
        INSTANCE.historyCursor = 0;
        INSTANCE.open();
      }
      else {
        INSTANCE.history.add(transactionId);
        INSTANCE.historyCursor = INSTANCE.history.size() - 1;
        INSTANCE.setTransactionId(transactionId);
        INSTANCE.getShell().forceActive();
      }
    }
  });
}
 
Example 7
Source File: NXTService.java    From offspring with MIT License 4 votes vote down vote up
@Override
public void initialize(IEventBroker _broker, final UISynchronize sync) {
  this.broker = _broker;

  logger.info("Initialize START");
  listeners = new NXTListeners(broker, this);

  H2ListenerHelper.getInstance().initialize(broker);
  initializing = true;

  /* Start the initialization process */
  broker.post(INxtService.TOPIC_INITIALIZATION_START, 1);

  /* The first block scanned signals reading of database is complete */
  broker.subscribe(INxtService.TOPIC_BLOCK_SCANNED, new EventHandler() {

    @Override
    public void handleEvent(Event event) {
      broker.unsubscribe(this);
      setScanning(true);
      broker.post(INxtService.TOPIC_BLOCK_SCANNER_START, 1);
    }
  });

  logger.info("NXT init START");

  try {
    /* Read the database file AND iterate over all records in database */
    Nxt.init(Config.properties);
  }
  catch (final Throwable t) {
    sync.syncExec(new Runnable() {

      @Override
      public void run() {
        MessageDialog
            .openError(
                Display.getDefault().getActiveShell(),
                "NXT initialization Error",
                "A fatal error occured initializing NXT.\n"
                    + "If this keeps occuring consider to delete NXT database folder.\n\n"
                    + t.toString());
      }
    });
    System.exit(-1);
    return;
  }

  logger.info("NXT init END");

  broker.post(INxtService.TOPIC_BLOCK_SCANNER_FINISHED, getBlockCount());

  broker.post(INxtService.TOPIC_INITIALIZATION_FINISHED, 1);
  setScanning(false);

  initializing = false;
  logger.info("Initialization COMPLETE");

  /* Nxt initialized and ready turn on forging for all accounts */
  sync.asyncExec(new Runnable() {

    @Override
    public void run() {
      for (IAccount account : unlockedAccounts) {
        account.startForging();
      }
    }
  });
}