コード例 #1
0
  protected void applyPersistedStates(MPart part) throws GkException {
    String baudrateStr =
        part.getPersistedState().get(SerialConnectionController.PERSISTED_BAUDRATE);

    if (StringUtils.isNotBlank(baudrateStr)) {
      LabeledValue<Integer> baudrate =
          GkUiUtils.getLabelledValueByKey(
              Integer.valueOf(baudrateStr), controller.getDataModel().getChoiceBaudrate());
      if (baudrate != null) {
        controller.getDataModel().setBaudrate(baudrate);
      }
    }

    String commPortStr =
        part.getPersistedState().get(SerialConnectionController.PERSISTED_COMMPORT);

    if (StringUtils.isNotBlank(baudrateStr)) {
      LabeledValue<String> commPort =
          GkUiUtils.getLabelledValueByKey(
              commPortStr, controller.getDataModel().getChoiceSerialPort());
      if (commPort != null) {
        controller.getDataModel().setSerialPort(commPort);
      }
    }
  }
コード例 #2
0
 @PersistState
 public void persist(MPart part) {
   if (controller.getDataModel() != null) {
     part.getPersistedState()
         .put(
             SerialConnectionController.PERSISTED_BAUDRATE,
             String.valueOf(controller.getDataModel().getBaudrate().getValue()));
     part.getPersistedState()
         .put(
             SerialConnectionController.PERSISTED_COMMPORT,
             controller.getDataModel().getSerialPort().getValue());
   }
 }
コード例 #3
0
ファイル: OutlineView.java プロジェクト: lunifera/grad
 /**
  * Returns the ID to find a proper service.
  *
  * @param mPart
  * @return
  */
 protected String getServiceID(MPart mPart) {
   String id = mPart.getPersistedState().get(IOutlineViewProvider.PROPERTY);
   if (id == null || id.isEmpty()) {
     id = mPart.getElementId();
   }
   return id;
 }
コード例 #4
0
 private MPart createPart(MPartDescriptor descriptor) {
   if (descriptor == null) {
     return null;
   }
   MPart part = modelService.createModelElement(MPart.class);
   part.setElementId(descriptor.getElementId());
   part.getMenus().addAll(EcoreUtil.copyAll(descriptor.getMenus()));
   if (descriptor.getToolbar() != null) {
     part.setToolbar((MToolBar) EcoreUtil.copy((EObject) descriptor.getToolbar()));
   }
   part.setContributorURI(descriptor.getContributorURI());
   part.setCloseable(descriptor.isCloseable());
   part.setContributionURI(descriptor.getContributionURI());
   part.setLabel(descriptor.getLabel());
   part.setIconURI(descriptor.getIconURI());
   part.setTooltip(descriptor.getTooltip());
   part.getHandlers().addAll(EcoreUtil.copyAll(descriptor.getHandlers()));
   part.getTags().addAll(descriptor.getTags());
   part.getPersistedState().putAll(descriptor.getPersistedState());
   part.getBindingContexts().addAll(descriptor.getBindingContexts());
   return part;
 }