コード例 #1
0
ファイル: InformationDialog.java プロジェクト: jongbok/notij
  protected Control createContents(Composite parent) {
    ViewForm form = new ViewForm(parent, SWT.NONE);
    form.setSize(400, 290);
    final Composite shell = new Composite(form.getShell(), SWT.NONE);
    Label lbApp1 = new Label(shell, SWT.NONE);
    lbApp1.setText("Version:");
    lbApp1.setBounds(10, 10, 50, 20);
    controls.add(lbApp1);
    Label lbApp2 = new Label(shell, SWT.NONE);
    lbApp2.setText("noti-J 1.0");
    lbApp2.setBounds(UIUtils.getBoundsH(lbApp1, 10, 100));
    controls.add(lbApp2);

    Label lbStatus1 = new Label(shell, SWT.NONE);
    lbStatus1.setText("State:");
    lbStatus1.setBounds(UIUtils.getBoundsV(lbApp1, 10));
    controls.add(lbStatus1);
    Label lbStatus2 = new Label(shell, SWT.NONE);
    lbStatus2.setText(connected ? "connected" : "disconnect");
    lbStatus2.setForeground(
        Display.getDefault().getSystemColor(connected ? SWT.COLOR_BLUE : SWT.COLOR_RED));
    lbStatus2.setBounds(UIUtils.getBoundsV(lbApp2, 10));
    controls.add(lbStatus2);

    Label lbUser1 = new Label(shell, SWT.NONE);
    lbUser1.setText("Account:");
    lbUser1.setBounds(UIUtils.getBoundsV(lbStatus1, 10));
    controls.add(lbUser1);
    Label lbUser2 = new Label(shell, SWT.NONE);
    lbUser2.setText(userid + "(" + userName + ")");
    lbUser2.setBounds(UIUtils.getBoundsV(lbStatus2, 10));
    controls.add(lbUser2);

    Label lbLic1 = new Label(shell, SWT.NONE);
    lbLic1.setText("License:");
    lbLic1.setBounds(UIUtils.getBoundsV(lbUser1, 10));
    controls.add(lbLic1);
    Label lbLic2 = new Label(shell, SWT.NONE);
    lbLic2.setText("GPL 3.0");
    lbLic2.setBounds(UIUtils.getBoundsV(lbUser2, 10));
    controls.add(lbLic2);

    Label lbDev1 = new Label(shell, SWT.NONE);
    lbDev1.setText("Author:");
    lbDev1.setBounds(UIUtils.getBoundsV(lbLic1, 10));
    controls.add(lbDev1);
    Label lbDev2 = new Label(shell, SWT.NONE);
    lbDev2.setText("Jong-Bok,Park([email protected])");
    lbDev2.setBounds(UIUtils.getBoundsV(lbLic2, 10, 300));
    controls.add(lbDev2);

    Text txError = new Text(shell, SWT.NONE | SWT.WRAP);
    txError.setText(errorMsg == null ? "" : errorMsg);
    txError.setBounds(UIUtils.getBoundsV(lbDev1, 10, 300, 100));
    txError.setEditable(false);
    controls.add(txError);
    controls.add(form);
    return form;
  }
コード例 #2
0
 public static void Storage() {
   if (ContextCompat.checkSelfPermission(
           UIUtils.getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE)
       != PackageManager.PERMISSION_GRANTED) {
     ActivityCompat.requestPermissions(
         UIUtils.getActivity(),
         new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE},
         Constant.WRITE_EXTERNAL_STORAGE_REQUEST_CODE);
   }
 }
コード例 #3
0
  @Override
  public JComponent getContent() {

    if (this.obj == null) {

      throw new IllegalStateException("No object set.");
    }

    // TODO: Make this nicer later.
    if (this.obj instanceof Chapter) {

      Chapter c = (Chapter) this.obj;

      JComponent t = UIUtils.getChapterInfoPreview(c, null, this.viewer);

      if (t == null) {

        // May be a fake chapter, return null.
        return null;
      }

      t.setSize(new Dimension(300, Short.MAX_VALUE));

      return t;

    } else {

      String firstLine = "<b><i>No description.</i></b>";

      String t = (obj.getDescription() != null ? obj.getDescription().getText() : null);

      if ((t != null) && (t.length() > 0)) {

        firstLine = new Paragraph(t, 0).getFirstSentence().getText();
      }

      JEditorPane desc = UIUtils.createHelpTextPane(firstLine, null);

      FormLayout fl = new FormLayout("380px", "p");

      PanelBuilder pb = new PanelBuilder(fl);

      CellConstraints cc = new CellConstraints();

      pb.add(desc, cc.xy(1, 1));

      desc.setAlignmentX(Component.LEFT_ALIGNMENT);

      JPanel p = pb.getPanel();
      p.setOpaque(true);
      p.setBackground(UIUtils.getComponentColor());

      return p;
    }
  }
コード例 #4
0
  public FindSynonymsActionHandler(String word, int position, Chapter c, AbstractEditorPanel p) {

    this.word = word;
    this.position = position;
    // this.chapter = c;
    this.editorPanel = p;
    this.projectViewer = this.editorPanel.getViewer();

    final FindSynonymsActionHandler _this = this;

    // Show a panel of all the items.
    this.popup =
        new QPopup(
            "Synonyms for: " + word,
            Environment.getIcon(Constants.FIND_ICON_NAME, Constants.ICON_POPUP),
            null);

    JButton close =
        UIUtils.createButton(
            Constants.CLOSE_ICON_NAME, Constants.ICON_MENU, "Click to close", null);

    List<JButton> buts = new ArrayList();
    buts.add(close);

    this.popup.getHeader().setControls(UIUtils.createButtonBar(buts));

    close.addActionListener(
        new ActionAdapter() {

          public void actionPerformed(ActionEvent ev) {

            _this.popup.setVisible(false);

            _this.editorPanel.getEditor().removeHighlight(_this.highlight);
          }
        });

    p.addPopup(this.popup, true, true);
    /*
          this.highlight = this.editorPanel.getEditor ().addHighlight (position,
                                                                       position + word.length (),
                                                                       null,
                                                                       true);
    */
    this.popup.setOpaque(false);
    this.popup.setVisible(false);

    this.popup.setDraggable(this.editorPanel);
  }
コード例 #5
0
ファイル: WiFiUtils.java プロジェクト: jonathan-caryl/iosched
 /**
  * Returns whether we should or should not offer to set up wifi. If asCard == true this will
  * decide whether or not to offer wifi setup actively (as a card, for instance). If asCard ==
  * false, this will return whether or not to offer wifi setup passively (in the overflow menu, for
  * instance).
  */
 public static boolean shouldOfferToSetupWifi(final Context context, boolean actively) {
   long now = UIUtils.getCurrentTime(context);
   if (now < Config.WIFI_SETUP_OFFER_START) {
     // too early to offer
     return false;
   }
   if (now > Config.CONFERENCE_END_MILLIS) {
     // too late
     return false;
   }
   if (!WiFiUtils.isWiFiEnabled(context)) {
     // no wifi, no offer
     return false;
   }
   if (!PrefUtils.isAttendeeAtVenue(context)) {
     // wifi setup not relevant
     return false;
   }
   if (WiFiUtils.isWiFiApConfigured(context)) {
     // already set up
     return false;
   }
   if (actively && PrefUtils.hasDeclinedWifiSetup(context)) {
     // user said no
     return false;
   }
   return true;
 }
コード例 #6
0
ファイル: ImageWorker.java プロジェクト: jpforny/Batuck
  /**
   * Load an image specified by the data parameter into an ImageView (override {@link
   * ImageWorker#processBitmap(Object)} to define the processing logic). A memory and disk cache
   * will be used if an {@link ImageCache} has been set using {@link ImageWorker#addImageCache}. If
   * the image is found in the memory cache, it is set immediately, otherwise an {@link AsyncTask}
   * will be created to asynchronously load the bitmap.
   *
   * @param data The URL of the image to download.
   * @param imageView The ImageView to bind the downloaded image to.
   */
  public void loadImage(Object data, ImageView imageView, Bitmap loadingBitmap) {
    if (data == null) {
      return;
    }

    Bitmap bitmap = null;

    if (mImageCache != null) {
      bitmap = mImageCache.getBitmapFromMemCache(String.valueOf(data));
    }

    if (bitmap != null) {
      // Bitmap found in memory cache
      imageView.setImageBitmap(bitmap);
    } else if (cancelPotentialWork(data, imageView)) {
      final BitmapWorkerTask task = new BitmapWorkerTask(imageView);
      final AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, loadingBitmap, task);
      imageView.setImageDrawable(asyncDrawable);

      if (UIUtils.hasHoneycomb()) {
        // On HC+ we execute on a dual thread executor. There really isn't much extra
        // benefit to having a really large pool of threads. Having more than one will
        // likely benefit network bottlenecks though.
        task.executeOnExecutor(DUAL_THREAD_EXECUTOR, data);
      } else {
        // Otherwise pre-HC the default is a thread pool executor (not ideal, serial
        // execution or a smaller number of threads would be better).
        task.execute(data);
      }
    }
  }
コード例 #7
0
 private void closeCardBrowser(int result) {
   setResult(result);
   finish();
   if (UIUtils.getApiLevel() > 4) {
     ActivityTransitionAnimation.slide(this, ActivityTransitionAnimation.RIGHT);
   }
 }
コード例 #8
0
 /** 获取指定路径的apk的资源 */
 @SuppressWarnings({"rawtypes", "unchecked"})
 public static Resources getAPKResources(String apkPath) throws Exception {
   Context context = UIUtils.getContext();
   if (null == context) {
     return null;
   }
   String PathAssetManager = "android.content.res.AssetManager";
   Class assetMagCls = Class.forName(PathAssetManager);
   Constructor assetMagCt = assetMagCls.getConstructor((Class[]) null);
   Object assetMag = assetMagCt.newInstance((Object[]) null);
   Class[] typeArgs = new Class[1];
   typeArgs[0] = String.class;
   Method assetMagAddAssetPathMtd = assetMagCls.getDeclaredMethod("addAssetPath", typeArgs);
   Object[] valueArgs = new Object[1];
   valueArgs[0] = apkPath;
   assetMagAddAssetPathMtd.invoke(assetMag, valueArgs);
   Resources res = context.getResources();
   typeArgs = new Class[3];
   typeArgs[0] = assetMag.getClass();
   typeArgs[1] = res.getDisplayMetrics().getClass();
   typeArgs[2] = res.getConfiguration().getClass();
   Constructor resCt = Resources.class.getConstructor(typeArgs);
   valueArgs = new Object[3];
   valueArgs[0] = assetMag;
   valueArgs[1] = res.getDisplayMetrics();
   valueArgs[2] = res.getConfiguration();
   res = (Resources) resCt.newInstance(valueArgs);
   return res;
 }
コード例 #9
0
  public HideablePopup(E viewer) {

    super(BoxLayout.Y_AXIS);

    this.viewer = viewer;

    this.setOpaque(true);
    this.setBackground(UIUtils.getComponentColor());
    this.setBorder(
        new CompoundBorder(
            com.quollwriter.ui.components.UIUtils.internalPanelDropShadow,
            UIUtils.createLineBorder()));

    final HideablePopup _this = this;

    this.addMouseListener(
        new MouseAdapter() {

          public void mouseEntered(MouseEvent ev) {

            if (_this.hideTimer != null) {

              _this.hideTimer.stop();
            }
          }

          public void mouseExited(MouseEvent ev) {

            if (_this.hideTimer != null) {

              Point p = new Point(0, 0);

              SwingUtilities.convertPointToScreen(p, _this);

              Rectangle tBounds = _this.getBounds(null);

              tBounds.x = p.x;
              tBounds.y = p.y;

              if (!tBounds.contains(ev.getLocationOnScreen())) {

                _this.hideTimer.start();
              }
            }
          }
        });
  }
コード例 #10
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case MENU_UNDO:
        // DeckTask.launchDeckTask(DeckTask.TASK_TYPE_UNDO, mUndoRedoHandler, new
        // DeckTask.TaskData(0, mDeck, 0,
        // true));
        return true;

      case MENU_ADD_NOTE:
        Intent intent = new Intent(CardBrowser.this, CardEditor.class);
        intent.putExtra(CardEditor.EXTRA_CALLER, CardEditor.CALLER_CARDBROWSER_ADD);
        startActivityForResult(intent, ADD_NOTE);
        if (UIUtils.getApiLevel() > 4) {
          ActivityTransitionAnimation.slide(CardBrowser.this, ActivityTransitionAnimation.LEFT);
        }
        return true;

      case MENU_SHOW_MARKED:
        mShowOnlyMarSus = true;
        mSearchEditText.setHint(R.string.card_browser_show_marked);
        mCards.clear();
        for (int i = 0; i < mAllCards.size(); i++) {
          int flags = Integer.parseInt(mAllCards.get(i).get("flags"));
          if (flags == 2 || flags == 3) {
            mCards.add(mAllCards.get(i));
          }
        }
        updateList();
        return true;

      case MENU_SELECT_SUSPENDED:
        mShowOnlyMarSus = true;
        mSearchEditText.setHint(R.string.card_browser_show_suspended);
        mCards.clear();
        for (int i = 0; i < mAllCards.size(); i++) {
          int flags = Integer.parseInt(mAllCards.get(i).get("flags"));
          if (flags == 1 || flags == 3) {
            mCards.add(mAllCards.get(i));
          }
        }
        updateList();
        return true;

      case MENU_SELECT_TAG:
        showDialog(DIALOG_TAGS);
        return true;

      case MENU_CHANGE_ORDER:
        showDialog(DIALOG_ORDER);
        return true;

      case MENU_FIELD:
        showDialog(DIALOG_FIELD);
        return true;
    }

    return false;
  }
コード例 #11
0
 private void updateList() {
   mCardsAdapter.notifyDataSetChanged();
   int count = mCards.size();
   UIUtils.setActionBarSubtitle(
       this,
       getResources()
           .getQuantityString(R.plurals.card_browser_subtitle, count, count, mAllCards.size()));
 }
コード例 #12
0
 @Override
 protected void onStop() {
   super.onStop();
   if (!isFinishing()) {
     WidgetStatus.update(this);
     UIUtils.saveCollectionInBackground(mCol);
   }
 }
コード例 #13
0
 /** 检测手机是否已插入SIM卡 */
 public static boolean isCheckSimCardAvailable() {
   Context context = UIUtils.getContext();
   if (null == context) {
     return false;
   }
   final TelephonyManager tm =
       (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
   return tm.getSimState() == TelephonyManager.SIM_STATE_READY;
 }
コード例 #14
0
  public List<FormItem> getExtraEditItems(ActionListener onSave) {

    List<FormItem> items = new ArrayList();
    items.add(new FormItem("Web Page", this.urlEdit));

    UIUtils.addDoActionOnReturnPressed(this.urlEdit, onSave);

    return items;
  }
コード例 #15
0
ファイル: DropDownItem.java プロジェクト: yatomiya/ye4
  protected void doDropDown() {
    Menu menu = new Menu(getShell(), SWT.POP_UP);
    createDropDownMenu(menu);
    if (menu.getItemCount() == 0) return;

    Point loc = UIUtils.calcPopupMenuLocation(this);
    menu.setLocation(loc);
    menu.setVisible(true);
  }
コード例 #16
0
 /** 获取单个应用最大分配内存,单位为byte */
 public static long getOneAppMaxMemory() {
   Context context = UIUtils.getContext();
   if (context == null) {
     return -1;
   }
   ActivityManager activityManager =
       (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
   return activityManager.getMemoryClass() * 1024 * 1024;
 }
コード例 #17
0
 /** 获得设备的纵向dpi */
 public static float getHeightDpi() {
   Context context = UIUtils.getContext();
   if (null == context) {
     return 0;
   }
   DisplayMetrics dm = new DisplayMetrics();
   dm = context.getApplicationContext().getResources().getDisplayMetrics();
   return dm.ydpi;
 }
コード例 #18
0
 /**
  * 得到屏幕的高度
  *
  * @param mContext
  * @return
  */
 public static int getScreenHeight() {
   Context context = UIUtils.getContext();
   if (null == context) {
     return 0;
   }
   DisplayMetrics dm = new DisplayMetrics();
   dm = context.getApplicationContext().getResources().getDisplayMetrics();
   return dm.heightPixels;
 }
コード例 #19
0
  void action() {

    if (this.data == null) {
      return;
    }

    final String ext = ShowFileLinkAction.getCommonDataExtension(this.data);

    // Si conocemos la extension, intentamos abrir el fichero. Si no, permitimos
    // guardarlo con la extension que se desee.
    if (ext != null) {
      try {
        final File tmp = File.createTempFile("afirma", "." + ext); // $NON-NLS-1$//$NON-NLS-2$
        tmp.deleteOnExit();
        final OutputStream fos = new FileOutputStream(tmp);
        final OutputStream bos = new BufferedOutputStream(fos);
        bos.write(this.data);
        bos.flush();
        bos.close();
        fos.close();
        Desktop.getDesktop().open(tmp);
      } catch (final Exception e) {
        UIUtils.showErrorMessage(
            null,
            SimpleAfirmaMessages.getString("ShowFileLinkAction.2")
                + " '"
                + ext
                + "'", //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
            SimpleAfirmaMessages.getString("SimpleAfirma.7"), // $NON-NLS-1$
            JOptionPane.ERROR_MESSAGE);
      }
    } else {
      try {
        FileUIManager.saveFile(
            null,
            this.data,
            null,
            null,
            null,
            null,
            SimpleAfirmaMessages.getString("ShowFileLinkAction.1") // $NON-NLS-1$
            );
      } catch (final IOException e) {
        Logger.getLogger("es.gob.afirma")
            .severe("No se ha podido guardar el fichero: " + e); // $NON-NLS-1$ //$NON-NLS-2$
        JOptionPane.showMessageDialog(
            null,
            "No se ha podido guardar el fichero",
            "Error",
            JOptionPane.ERROR_MESSAGE); // $NON-NLS-1$ //$NON-NLS-2$
      } catch (final AOCancelledOperationException e) {
        Logger.getLogger("es.gob.afirma")
            .warning("Operacion cancelada por el usuario"); // $NON-NLS-1$ //$NON-NLS-2$
      }
    }
  }
コード例 #20
0
 private void execute(String type) {
   UIUtils.dispatchCloseEvent(this);
   new ShellInfoDialog(
       null,
       status.getAddress(),
       status.getName(),
       new String[] {status.getType()},
       status.getCatalog(),
       type);
 }
コード例 #21
0
 /** 手机低内存运行阀值,单位为byte */
 public static long getThresholdMemory() {
   Context context = UIUtils.getContext();
   if (context == null) {
     return -1;
   }
   ActivityManager activityManager =
       (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
   ActivityManager.MemoryInfo info = new ActivityManager.MemoryInfo();
   activityManager.getMemoryInfo(info);
   return info.threshold;
 }
コード例 #22
0
ファイル: UIUtilsTest.java プロジェクト: kyungkoo/iosched
  @Test
  public void startTimeToDayIndex_FirstDay_ReturnsZero() {
    // Given a start time 1 hour after the start of the conference
    long startTime = Config.CONFERENCE_START_MILLIS + TimeUtils.HOUR * 1;

    // When getting the day index for the start time
    int index = UIUtils.startTimeToDayIndex(startTime);

    // Then the index is 0
    assertThat(index, is(0));
  }
コード例 #23
0
ファイル: UIUtilsTest.java プロジェクト: kyungkoo/iosched
  @Test
  public void startTimeToDayIndex_BeforeStart_ReturnsZero() {
    // Given a start time 24 hours before the start of the conference
    long startTime = Config.CONFERENCE_START_MILLIS - TimeUtils.HOUR * 24;

    // When getting the day index for the start time
    int index = UIUtils.startTimeToDayIndex(startTime);

    // Then the index is 0
    assertThat(index, is(0));
  }
コード例 #24
0
 /** 返回本地手机号码,这个号码不一定能获取到 */
 public static String getNativePhoneNumber() {
   Context context = UIUtils.getContext();
   if (null == context) {
     return null;
   }
   TelephonyManager telephonyManager;
   telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
   String NativePhoneNumber = null;
   NativePhoneNumber = telephonyManager.getLine1Number();
   return NativePhoneNumber;
 }
コード例 #25
0
  public void submit() {

    Long selectedDepartingFlightId = sharedAirSearchCriteria.getSelectedDepartingFlightId();
    Long selectedReturnFlightId = sharedAirSearchCriteria.getSelectedReturnFlightId();
    FlightDetail departingFlight =
        airBookManager.findFlightByAvailableFlight(selectedDepartingFlightId);
    FlightDetail returnFlight = airBookManager.findFlightByAvailableFlight(selectedReturnFlightId);
    UniversalRecord book =
        airBookManager.book(
            departingFlight,
            returnFlight,
            airBookManager.getInializedPassengerDetailInstance(),
            airBookManager.getInializedFormOfPaymentInstance());
    sharedAirSearchCriteria.setUniversalRecordId(book.getId());
    Logger.getLogger(AirSearchBean.class.getName())
        .log(Level.INFO, "fop: {0} passenger", new String[] {fop.toString(), passenger.toString()});

    UIUtils.pause(1);
    UIUtils.ajaxRedirect("/AirBookSuccess.jsf");
  }
コード例 #26
0
ファイル: Reviewer.java プロジェクト: JoseFaeti/Anki-Android
  @Override
  protected void onStop() {
    super.onStop();

    if (!isFinishing()) {
      if (AnkiDroidApp.colIsOpen()) {
        WidgetStatus.update(this, mSched.progressToday(null, mCurrentCard, true));
      }
    }
    UIUtils.saveCollectionInBackground();
  }
コード例 #27
0
 /** 获取系统中的Library包 */
 public static List<String> getSystemLibs() {
   Context context = UIUtils.getContext();
   if (null == context) {
     return null;
   }
   PackageManager pm = context.getPackageManager();
   String[] libNames = pm.getSystemSharedLibraryNames();
   List<String> listLibNames = Arrays.asList(libNames);
   LogUtils.d("SystemLibs: " + listLibNames);
   return listLibNames;
 }
コード例 #28
0
 /** 手机是否处于低内存运行 */
 public static boolean isLowMemory() {
   Context context = UIUtils.getContext();
   if (context == null) {
     return false;
   }
   ActivityManager activityManager =
       (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
   ActivityManager.MemoryInfo info = new ActivityManager.MemoryInfo();
   activityManager.getMemoryInfo(info);
   return info.lowMemory;
 }
コード例 #29
0
ファイル: UIUtilsTest.java プロジェクト: kyungkoo/iosched
  @Test
  public void startTimeToDayIndex_AfterEnd_ReturnsLastDay() {
    // Given a start time 24 hours after the start of the conference
    long startTime = Config.CONFERENCE_END_MILLIS + TimeUtils.HOUR * 24;

    // When getting the day index for the start time
    int index = UIUtils.startTimeToDayIndex(startTime);

    // Then the index is the last day of the conference
    int lastDay = Config.CONFERENCE_DAYS.length - 1;
    assertThat(index, is(lastDay));
  }
コード例 #30
0
 /** 获取屏幕的分辨率 */
 @SuppressWarnings("deprecation")
 public static int[] getResolution() {
   Context context = UIUtils.getContext();
   if (null == context) {
     return null;
   }
   WindowManager windowMgr = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
   int[] res = new int[2];
   res[0] = windowMgr.getDefaultDisplay().getWidth();
   res[1] = windowMgr.getDefaultDisplay().getHeight();
   return res;
 }