@Test
  public void unregisterProducerInHandler() throws Exception {
    final Object producer =
        new Object() {
          private int calls = 0;

          @Produce
          public String produceString() {
            calls++;
            if (calls > 1) {
              fail("Should only have been called once, then unregistered and never called again.");
            }
            return "Please enjoy this hand-crafted String.";
          }
        };
    bus.register(producer);
    bus.register(
        new Object() {
          @Subscribe
          public void firstUnsubscribeTheProducer(String produced) {
            bus.unregister(producer);
          }

          @Subscribe
          public void shouldNeverBeCalled(String uhoh) {
            fail("Shouldn't receive events from an unregistered producer.");
          }
        });
  }
 /**
  * Méthode MonterDansBus
  *
  * <p>Vérifie l'état du festivalier Si festivalier dans l'état B Alors tant qu'il n'est pas dans
  * l'état C il tente de monter dans un bus (parcours des bus présent) Si pas de bus ou bus tout
  * complet, attente d'être notifié par l'arrivée d'un bus Si le festivalier rentre dans le bus, il
  * est ajouté dans la liste des festivalier du bus et son état passe à C
  *
  * @param f Festivalier - Le festivalier qui monte dans le bus
  */
 public synchronized void monterDansBus(Festivalier f) {
   // Seul les festivaliers aillant un billet peuvent monter
   if (f.getEtatF().equals("B")) {
     // Tant que le festivalier n'est pas dans un bus
     while (!f.getEtatF().equals("C")) {
       // Si il n'a pas reussi a monter dans un bus
       for (Bus bus : this.buses) {
         // Si le bus n'est pas complet, le festivalier monte dedans
         if (!bus.estComplet() && f.getEtatF().equals("B")) {
           bus.ajoutFestivalier(f);
           // Le festivalier est dedans, l'etat passe a C, on sort de la boucle
           break;
         }
       }
       // Si il a vérifié tous les bus et qu'ils sont tous pleins
       if (f.getEtatF().equals("B")) {
         try {
           // Il attend d'etre notifie par l'arrivee d'un bus
           this.wait();
         } catch (InterruptedException e) {
           e.printStackTrace();
         }
       }
     }
   }
 }
Example #3
0
 private void assertConsumerWorks() {
   assertNull(consumer.hello);
   bus.publish(HELLO);
   assertNotNull(consumer.hello);
   assertEquals(consumer.hello.name(), "hello");
   assertNull(consumer.goodbye);
   bus.publish(GOODBYE);
   assertNotNull(consumer.goodbye);
   assertEquals(consumer.goodbye.name(), GOODBYE.name());
 }
Example #4
0
  /* take things from the bus */
  public void ClockCycleRead(int clock) {
    /* handle writing to internal registers */
    if (W_LALU) {
      Lt_ALU = bus.getValue();
      ALUopstart = clock + 20;
    }
    if (W_RALU) {
      Rt_ALU = bus.getValue();
      ALUopstart = clock + 20;
    }

    clearGates();
  }
  @Test
  public void unregisterInHandlerWhenEventProduced() throws Exception {
    UnregisteringStringCatcher catcher = new UnregisteringStringCatcher(bus);

    bus.register(new StringProducer());
    bus.register(catcher);
    assertEquals(Arrays.asList(StringProducer.VALUE), catcher.getEvents());

    bus.post(EVENT);
    bus.post(EVENT);
    assertEquals(
        "Shouldn't catch any more events when unregistered.",
        Arrays.asList(StringProducer.VALUE),
        catcher.getEvents());
  }
  /** @see Editor#addSelectorForm() */
  @Override
  public void addSelectorForm() {
    JComboBox<Bus> jcbBus;
    Bus[] buses = Bus.getBusArray(this);
    if (isDeleteOperation) {
      jcbBus = new JComboBox<Bus>();
      jcbBus.setPreferredSize(fieldSize);
      for (Bus b : buses) {
        if (b.id != item.id) {
          jcbBus.addItem(b);
        }
      }
    } else {
      jcbBus = new JComboBox<Bus>(buses);
      jcbBus.setPreferredSize(fieldSize);
      jcbBus.setSelectedIndex(-1);
      if (item != null) {
        for (int i = 0; i < buses.length; i++) {
          if (buses[i].id == item.id) {
            jcbBus.setSelectedIndex(i);
          }
        }
      }
    }

    model = jcbBus;
    addField(TABLE_BUS_BUSID, model);
  }
 /** @see Editor#refreshItem() */
 @Override
 public void refreshItem() {
   if (isEditorForm) {
     JTextField jtfModel = (JTextField) model;
     JFormattedTextField jftfYear = (JFormattedTextField) year;
     if (item == null) {
       item =
           new Bus(
               Bus.getNextBusID(this),
               jtfModel.getText(),
               jftfYear.getText().replaceAll("[^0-9]", ""));
     } else {
       item.model = jtfModel.getText();
       item.year = jftfYear.getText().replaceAll("[^0-9]", "");
     }
   } else {
     JComboBox<Bus> jcbBus = (JComboBox) model;
     Bus bus = (Bus) jcbBus.getSelectedItem();
     if (item == null) {
       item = bus;
     } else {
       item.id = bus.id;
       item.model = bus.model;
       item.year = bus.year;
     }
   }
 }
  @Test
  public void unregisterInHandler() {
    UnregisteringStringCatcher catcher = new UnregisteringStringCatcher(bus);
    bus.register(catcher);
    bus.post(EVENT);

    assertEquals(
        "One correct event should be delivered.", Arrays.asList(EVENT), catcher.getEvents());

    bus.post(EVENT);
    bus.post(EVENT);
    assertEquals(
        "Shouldn't catch any more events when unregistered.",
        Arrays.asList(EVENT),
        catcher.getEvents());
  }
  // sends a value from the appropriate stack (at sp-1) to the ram at the given index
  // and increments sp.
  private void popToRAM(int stackID, int index) throws ProgramException {
    short newSP = (short) (getSP() - 1);
    bus.send((stackID == MAIN_STACK ? stackSegment : workingStackSegment), newSP, ram, index);

    checkSP(newSP);
    setSP(newSP);
  }
 private void u()
 {
   akh localakh = a.mPreviewConfiguration;
   if ((localakh != null) && (mShouldHideSystemUi)) {
     Z.a(new bet(false));
   }
 }
  // Push a value from the calculator at the given index into the appropriate stack.
  private void pushFromCalculator(int stackID, int index) throws ProgramException {
    short sp = getSP();
    bus.send(calculator, index, (stackID == MAIN_STACK ? stackSegment : workingStackSegment), sp);

    checkSP((short) (sp + 1));
    setSP((short) (sp + 1));
  }
Example #12
0
  public void initSeats(int numSeats, int numColumns) {
    row = 0;
    columns = 0;
    countSeats = 0;

    SeatShape.columns = numColumns;
    gridPane.hgapProperty().unbind();
    gridPane.hgapProperty().bind(bus.widthProperty().divide(numColumns).divide(8));

    seatsList.clear();
    gridPane.getChildren().clear();

    while (columns < numColumns) {
      while (row < NUM_ROWS + 1) {
        if (countSeats < numSeats) {
          SeatShape seatsShape = new SeatShape(countSeats + 1, gridPane.hgapProperty(), bus);
          if (row != 2) {
            countSeats++;
            seatsList.add(seatsShape);
          } else {
            seatsShape.setVisible(false);
          }
          seatsShape.setOnMouseClicked(
              (MouseEvent evt) -> {
                ((SeatShape) evt.getSource()).toogle();
              });
          gridPane.add(seatsShape, columns, row);
        }

        row++;
      }
      row = 0;
      columns++;
    }
  }
Example #13
0
  /* put things on the bus */
  public void ClockCycleWrite(int clock) {
    if (StatusChanged) ALUopstart = clock;

    /* see if we can assert the result yet */
    if (clock == ALUopstart + 60) {
      int op;
      long rightop = Rt_ALU;

      if (!IRALU) /* ALUop from IR */ op = ir.getALUop();
      else /* ALUop from microcode */ {
        rightop = ALU_PLUS2 ? 2 : Rt_ALU;
        op = MC_op;
      }

      /* do the operations: */
      switch (op) {
        default:
        case 0: /* nop */
          ALUresult = 0;
          break;
        case 1:
          ALUresult = Lt_ALU + rightop;
          break;
        case 2:
          ALUresult = Lt_ALU - rightop;
          break;
        case 3:
          ALUresult = Lt_ALU & rightop;
          break;
        case 4:
          ALUresult = Lt_ALU | rightop;
          break;
        case 5:
          ALUresult = Lt_ALU ^ rightop;
          break;
        case 6:
          ALUresult = (0xfffff) ^ rightop;
          break;
      }

      /* set SR as appropriate. */
      if (!sr.getSHFALU() && sr.getW_SR12()) {
        sr.setSR1(ALUresult > 0);
        sr.setSR2(ALUresult < 0);
      }
      ALUopstart = 0;
    }

    /* read from internal register */
    if (R_ALU) {
      if (W_LALU || (W_RALU && !ALU_PLUS2))
        throw new IllegalOperation("Writing to ALU registers while reading ALU output");
      bus.setValue(ALUresult);
    }
  }
 public void onResume()
 {
   super.onResume();
   if (a != null) {
     a.b();
   }
   Z.c(b.getCaptionView());
   g.setDrawingEnabled(k);
   b.b(false);
   a(k);
 }
 protected final void e()
 {
   u();
   N.a("FIRST_MEDIA_OPENED");
   Y.b();
   w();
   J = false;
   if ((v != awf.d(getActivity())) || (R != null)) {
     x();
   }
   if (a != null)
   {
     v();
     t();
     a.f();
   }
   Z.a(new bfk(TitleBarManager.Visibility.HIDDEN));
   SnapEditorView localSnapEditorView;
   boolean bool;
   if ((a != null) && (avr.a(a)))
   {
     b.a((aku)a);
     localSnapEditorView = b;
     if (!D.isChecked())
     {
       bool = true;
       localSnapEditorView.setAudible(bool);
     }
   }
   for (;;)
   {
     localSnapEditorView = b;
     localSnapEditorView.a(c.b.a, false);
     return;
     bool = false;
     break;
     if (a.mSnapType != Mediabryo.SnapType.DISCOVER) {
       Z.a(new bbx(-1));
     }
   }
 }
Example #16
0
  public boolean insertarBus(Bus bus) {
    conexionBD.conectar();
    boolean exito = false;

    String query =
        "INSERT INTO bus (bus_serial, bus_tipo, bus_capacidad, ruta_nombre, bus_estado) VALUES (?,?,?,?,?);";

    try {
      PreparedStatement st = conexionBD.conexion.prepareStatement(query);

      st.setString(1, bus.getSerial());
      st.setString(2, bus.getTipo());
      st.setInt(3, bus.getCapacidad());

      if (bus.getRuta().isEmpty()) {
        st.setNull(4, java.sql.Types.VARCHAR);
      } else {
        st.setString(4, bus.getRuta());
      }

      st.setBoolean(5, bus.isEstado());

      int resultado = st.executeUpdate();
      exito = true;
    } catch (SQLException ex) {
      Logger.getLogger(BusDAO.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
      if (conexionBD != null) {
        conexionBD.cerrarConexion();
      }
    }

    return exito;
  }
  // sends a value from the appropriate stack (at sp-1) to the given segment at the given index
  // and increments sp.
  private void popToSegment(int stackID, short segmentCode, int index) throws ProgramException {
    short newSP = (short) (getSP() - 1);
    MemorySegment segment =
        (segmentCode == HVMInstructionSet.STATIC_SEGMENT_CODE)
            ? staticSegment
            : segments[segmentCode];

    checkSegmentIndex(segment, segmentCode, index);
    bus.send((stackID == MAIN_STACK ? stackSegment : workingStackSegment), newSP, segment, index);

    checkSP(newSP);
    setSP(newSP);
  }
  // sends a value from the given segment at the the given index to the appropriate stack (at sp)
  // and increments sp.
  private void pushFromSegment(int stackID, short segmentCode, int index) throws ProgramException {
    short sp = getSP();
    MemorySegment segment =
        (segmentCode == HVMInstructionSet.STATIC_SEGMENT_CODE)
            ? staticSegment
            : segments[segmentCode];

    checkSegmentIndex(segment, segmentCode, index);
    bus.send(segment, index, (stackID == MAIN_STACK ? stackSegment : workingStackSegment), sp);

    checkSP((short) (sp + 1));
    setSP((short) (sp + 1));
  }
 public void onPause()
 {
   super.onPause();
   if (a != null) {
     a.c();
   }
   if ((!getActivity().isChangingConfigurations()) && (b.getCaptionView() != null)) {
     b.getCaptionView().a(false);
   }
   R = b.a();
   b.c();
   b.g();
   Z.b(b.getCaptionView());
 }
Example #20
0
 public BusPlace() {
   seatsList = new ArrayList<>();
   bus.setArcHeight(8);
   bus.setArcWidth(8);
   bus.setFill(Color.TRANSPARENT);
   bus.setStrokeWidth(2);
   bus.setWidth(500);
   bus.setHeight(200);
   bus.setStyle("-fx-stroke:-color-accent");
   gridPane.setAlignment(Pos.CENTER);
   StackPane.setAlignment(gridPane, Pos.CENTER);
   this.getChildren().addAll(bus, gridPane);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_swipe_finish_father);
    textView = (TextView) findViewById(R.id.time);

    Bus.instance().register(this);
    //        new CountDownTimer(1000000, 1000) {
    //            @Override
    //            public void onTick(long millisUntilFinished) {
    //                textView.setText(System.currentTimeMillis() + "");
    //            }
    //
    //            @Override
    //            public void onFinish() {
    //            }
    //        }.start();
  }
 public void onDestroyView()
 {
   super.onDestroyView();
   if (!b.getCaptionView().i()) {
     AnalyticsEvents.h();
   }
   if (g.getNumberOfStrokes() > 0) {
     AnalyticsEvents.b(g.getNumberOfStrokes());
   }
   if (O.b + O.c > 0) {
     AnalyticsEvents.a(a);
   }
   og.a();
   og.d(a);
   b.b();
   b = null;
   R = null;
   WindowManager.LayoutParams localLayoutParams = J().getAttributes();
   flags |= 0x200;
   J().setAttributes(localLayoutParams);
   Z.a(new bbx(1));
 }
Example #23
0
  public boolean modificarBus(Bus bus) {
    conexionBD.conectar();
    boolean exito = false;

    String query =
        "UPDATE bus SET "
            // + "bus_serial = ?, "
            + "bus_tipo = ?, "
            + "bus_capacidad = ?, "
            + "ruta_nombre = ?, "
            + "bus_estado = ? "
            + "WHERE bus_serial = ?;";

    try {
      PreparedStatement st = conexionBD.conexion.prepareStatement(query);

      st.setString(5, bus.getSerial());
      st.setString(1, bus.getTipo());
      st.setInt(2, bus.getCapacidad());

      if (bus.getRuta().isEmpty()) {
        st.setNull(3, java.sql.Types.VARCHAR);
      } else {
        st.setString(3, bus.getRuta());
      }

      st.setBoolean(4, bus.isEstado());

      int resultado = st.executeUpdate();
      exito = true;
    } catch (SQLException ex) {
      Logger.getLogger(BusDAO.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
      if (conexionBD != null) {
        conexionBD.cerrarConexion();
      }
    }

    return exito;
  }
 public final boolean g()
 {
   if (L.c())
   {
     m();
     return true;
   }
   if (ab)
   {
     p();
     return true;
   }
   if ((l) || (b == null) || (b.getCaptionView() == null) || (g == null)) {
     return false;
   }
   Object localObject = b;
   if ((a.g()) && ((a instanceof FatCaptionView))) {
     a.a(true);
   }
   for (int i1 = 1; i1 != 0; i1 = 0) {
     return true;
   }
   if (g.c())
   {
     new ara(getActivity(), getString(2131492920))
     {
       protected final void a()
       {
         SnapPreviewFragment.a(SnapPreviewFragment.this);
         FragmentActivity localFragmentActivity = getActivity();
         if (localFragmentActivity != null) {
           localFragmentActivity.onBackPressed();
         }
       }
       
       protected final void b() {}
     }.show();
     return true;
   }
   if ((a != null) && (avr.a(a)) && (e == null)) {
     CameraEventAnalytics.a().a(CameraEventAnalytics.CameraContext.CANCEL_PREVIEW);
   }
   if ((a == null) || (e != null)) {}
   for (;;)
   {
     Z.a(new bbq(CameraDisplayState.SHOW));
     if (H == null) {
       break;
     }
     Z.a(new bbt());
     return true;
     if (a.mSnapType == Mediabryo.SnapType.DISCOVER)
     {
       T.b(a);
     }
     else
     {
       localObject = S;
       aji localaji = a;
       b.b(localaji);
       if ((localaji instanceof aku))
       {
         localObject = ((aku)localaji).n();
         if (localObject != null) {
           aya.a((String)localObject);
         }
       }
     }
   }
   return false;
 }
 private void x()
 {
   Z.a(new bfk(TitleBarManager.Visibility.HIDDEN));
   int i1;
   label299:
   boolean bool;
   label316:
   label336:
   of localof;
   EasyMetric localEasyMetric;
   if (avr.a(a))
   {
     y.setVisibility(4);
     h.setVisibility(8);
     D.setVisibility(0);
     if (getUserVisibleHint()) {
       Z.a(new bbx(1));
     }
     s.setOnClickListener(new View.OnClickListener()
     {
       public final void onClick(View paramAnonymousView)
       {
         ((InputMethodManager)SnapPreviewFragment.a(SnapPreviewFragment.this, "input_method")).hideSoftInputFromWindow(SnapPreviewFragment.b(SnapPreviewFragment.this).getApplicationWindowToken(), 0);
         getActivity().onBackPressed();
       }
     });
     m.setOnClickListener(new View.OnClickListener()
     {
       public final void onClick(View paramAnonymousView)
       {
         if ((SnapPreviewFragment.c(SnapPreviewFragment.this).getCaptionView().i()) && (!SnapPreviewFragment.c(SnapPreviewFragment.this).getCaptionView().g()))
         {
           SnapPreviewFragment.c(SnapPreviewFragment.this).getCaptionView().f();
           return;
         }
         SnapPreviewFragment.c(SnapPreviewFragment.this).a(true);
       }
     });
     o.a(new bhr.a()
     {
       public final void a(View paramAnonymousView)
       {
         ((ImageButton)SnapPreviewFragment.e(SnapPreviewFragment.this).a()).setOnClickListener(new View.OnClickListener()
         {
           public final void onClick(View paramAnonymous2View)
           {
             SnapPreviewFragment.d(SnapPreviewFragment.this);
           }
         });
         ((ImageButton)SnapPreviewFragment.g(SnapPreviewFragment.this).a()).setOnClickListener(new View.OnClickListener()
         {
           public final void onClick(View paramAnonymous2View)
           {
             SnapPreviewFragment.f(SnapPreviewFragment.this);
           }
         });
       }
     });
     i.setOnClickListener(new View.OnClickListener()
     {
       public final void onClick(View paramAnonymousView)
       {
         AnalyticsEvents.i();
         SnapPreviewFragment.d(SnapPreviewFragment.this);
       }
     });
     t.setOnClickListener(new View.OnClickListener()
     {
       public final void onClick(View paramAnonymousView)
       {
         SnapPreviewFragment.h(SnapPreviewFragment.this);
         imMediaMailingMetadata.mSavedInGallery = true;
       }
     });
     z.a(new bhr.a()
     {
       public final void a(View paramAnonymousView)
       {
         SnapPreviewFragment.j(SnapPreviewFragment.this);
       }
     });
     y.setOnClickListener(new View.OnClickListener()
     {
       public final void onClick(View paramAnonymousView)
       {
         if (!SnapPreviewFragment.k(SnapPreviewFragment.this).c())
         {
           if (SnapPreviewFragment.l(SnapPreviewFragment.this)) {
             SnapPreviewFragment.d(SnapPreviewFragment.this);
           }
           SnapPreviewFragment.m(SnapPreviewFragment.this);
         }
       }
     });
     L.a(new bhr.a()
     {
       public final void a(View paramAnonymousView)
       {
         ((ListView)paramAnonymousView.findViewById(2131362726)).setAdapter(c);
       }
     });
     A.setOnClickListener(new View.OnClickListener()
     {
       public final void onClick(View paramAnonymousView)
       {
         if (akr.J())
         {
           SnapPreviewFragment.n(SnapPreviewFragment.this).show();
           return;
         }
         if (akk.a().d().size() > 1)
         {
           SnapPreviewFragment.o(SnapPreviewFragment.this);
           return;
         }
         SnapPreviewFragment.p(SnapPreviewFragment.this);
       }
     });
     v();
     i1 = D();
     B = i1;
     h.setText(String.valueOf(i1));
     I.setOnClickListener(new View.OnClickListener()
     {
       public final void onClick(View paramAnonymousView)
       {
         if (!SnapPreviewFragment.q(SnapPreviewFragment.this))
         {
           rmPrepareSnapMetric = EasyMetric.EasyMetricFactory.b("PREPARE_SNAP").b();
           SnapPreviewFragment.s(SnapPreviewFragment.this);
         }
         SnapPreviewFragment.t(SnapPreviewFragment.this);
       }
     });
     D.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
     {
       public final void onCheckedChanged(CompoundButton paramAnonymousCompoundButton, boolean paramAnonymousBoolean)
       {
         paramAnonymousCompoundButton = SnapPreviewFragment.c(SnapPreviewFragment.this);
         if (!paramAnonymousBoolean) {}
         for (paramAnonymousBoolean = true;; paramAnonymousBoolean = false)
         {
           paramAnonymousCompoundButton.setAudible(paramAnonymousBoolean);
           return;
         }
       }
     });
     b.getCaptionView().setIsVideoSnap(avr.a(a));
     if (R != null) {
       break label541;
     }
     b.setMediabryo(a);
     localObject = b;
     if (D.isChecked()) {
       break label560;
     }
     bool = true;
     ((SnapEditorView)localObject).setAudible(bool);
     localObject = m;
     if (!k) {
       break label565;
     }
     i1 = 8;
     ((Button)localObject).setVisibility(i1);
     if (b.getSwipeFilterType() == FilterPageType.TURN_ON_FILTERS_PAGE)
     {
       if (ad != null)
       {
         ad.a = true;
         ad = null;
       }
       i.setVisibility(8);
       r.setVisibility(8);
       s.setVisibility(8);
     }
     g.a(v);
     v = awf.d(getActivity());
     localof = U;
     bool = awf.b(v);
     if (mSnapCaptureMetric != null)
     {
       localEasyMetric = mSnapCaptureMetric;
       if (!bool) {
         break label570;
       }
     }
   }
   label541:
   label560:
   label565:
   label570:
   for (Object localObject = "portrait";; localObject = "landscape")
   {
     localEasyMetric.a("orientation", localObject).b(false);
     mSnapCaptureMetric = null;
     localof.b();
     O.a = a.h();
     return;
     if ((getUserVisibleHint()) && (a.mSnapType != Mediabryo.SnapType.DISCOVER)) {
       Z.a(new bbx(-1));
     }
     t();
     break;
     b.a(R);
     R = null;
     break label299;
     bool = false;
     break label316;
     i1 = 0;
     break label336;
   }
 }
Example #26
0
 public int getDistanceToDestinationCost(StopOrHub destination) {
   return bus.getDistanceFromTo(location, destination.getLocation()) * bus.getMileageCost();
 }
Example #27
0
 public int getDistanceFrom(BusOrStop busOrStop) {
   return bus.getDistanceFromTo(busOrStop.getLocation(), location);
 }
Example #28
0
 public int getDistanceFromPreviousCost() {
   if (previousBusOrStop == null) {
     return 0;
   }
   return getDistanceFrom(previousBusOrStop) * bus.getMileageCost();
 }
Example #29
0
 @Override
 public void onResume() {
   super.onResume();
   Bus.getInstance().post(new JobListingResumed());
 }
Example #30
0
 public void setOnSeatChange(EventHandler<ActionEvent> evt) {
   bus.setOnSeatChange(evt);
 }