Beispiel #1
0
 private Menu createMenu() {
   Menu menu = new Menu();
   menu.add(new MenuItem("Menu Item 1"));
   menu.add(new MenuItem("Menu Item 2"));
   menu.add(new MenuItem("Menu Item 3"));
   return menu;
 }
Beispiel #2
0
 /**
  * {@inheritDoc}
  *
  * @throws IllegalArgumentException if the specified widget is not a {@link StartToolMenuItem}
  */
 @Override
 public void add(Widget child) {
   if (!(child instanceof StartToolMenuItem)) {
     throw new IllegalArgumentException("Widget is not a StartToolMenuItem");
   }
   super.add(child);
 }
  private void initGUI() {
    toolBar = new ToolBar();
    TextButton userButton = new TextButton("Profile");
    forumButton = new TextButton("Forum");
    TextButton chatButton = new TextButton("Chat");
    lecturesButton = new TextButton("Lectures", ELearningController.ICONS.lectures());
    showProfileItem = new MenuItem("Show profile");
    changePasswordItem = new MenuItem("Change Password");
    viewLogsItem = new MenuItem("View logs");
    logoutItem = new MenuItem("Logout");
    userMenu = new Menu();
    Menu lecturesMenu = new Menu();
    userLecturesItem = new MenuItem("My Lectures");
    unenrolledLecturesItem = new MenuItem("Unenrolled Lectures");

    unenrolledLecturesItem.setSubMenu(new GridMenu(userLecturesView));

    logoutItem.setIcon(ELearningController.ICONS.logout());
    userMenu.add(showProfileItem);
    userMenu.add(viewLogsItem);
    userMenu.add(changePasswordItem);
    userMenu.add(logoutItem);

    lecturesMenu.add(userLecturesItem);
    lecturesMenu.add(unenrolledLecturesItem);
    lecturesButton.setMenu(lecturesMenu);

    lecturesButton.setWidth(100);
    userButton.setWidth(100);
    userButton.setIcon(ELearningController.ICONS.profile());
    userButton.setMenu(userMenu);
    forumButton.setWidth(80);
    forumButton.setIcon(ELearningController.ICONS.forum());
    chatButton.setWidth(80);
    chatButton.setIcon(ELearningController.ICONS.chat());

    toolBar.setHorizontalSpacing(5);
    toolBar.add(lecturesButton);
    toolBar.add(userButton);
    toolBar.add(forumButton);
    toolBar.add(chatButton);

    if (addSettingsButton) {
      settingsButton = new TextButton("", ELearningController.ICONS.settings());
      toolBar.add(settingsButton);
    }
    toolBar.setWidth(455);
  }
  public ArchiveView(final ArchiveHandler archiveHandler, ListStore<Device> deviceStore) {
    this.archiveHandler = archiveHandler;
    deviceStore.addStoreHandlers(deviceStoreHandlers);
    this.deviceStore = deviceStore;

    DeviceProperties deviceProperties = GWT.create(DeviceProperties.class);
    deviceCombo = new ComboBox<Device>(deviceStore, deviceProperties.label());

    // Element that displays the current track color
    styleButtonTrackColor = new TextButton();
    styleButtonTrackColor
        .getElement()
        .getStyle()
        .setProperty("backgroundColor", "#".concat(style.DEFAULT_COLOR));
    styleButtonTrackColor.getElement().getStyle().setCursor(Style.Cursor.TEXT);
    // Menu with the small palette
    smallColorMenu = new ExtColorMenu(ArchiveStyle.COLORS, ArchiveStyle.COLORS);
    smallColorMenu.setColor(ArchiveStyle.DEFAULT_COLOR);
    smallColorMenu
        .getPalette()
        .addValueChangeHandler(
            new ValueChangeHandler<String>() {
              @Override
              public void onValueChange(ValueChangeEvent<String> event) {
                style.setTrackColor(event.getValue());
                smallColorMenu.hide(true);
                fullColorMenu.getPalette().setValue("", false);
                styleButtonTrackColor
                    .getElement()
                    .getStyle()
                    .setProperty("backgroundColor", "#".concat(style.getTrackColor()));
              }
            });
    // Menu with the complete palette
    fullColorMenu = new ColorMenu();
    fullColorMenu
        .getPalette()
        .addValueChangeHandler(
            new ValueChangeHandler<String>() {
              @Override
              public void onValueChange(ValueChangeEvent<String> event) {
                style.setTrackColor(event.getValue());
                fullColorMenu.hide(true);
                smallColorMenu.getPalette().setValue("", false);
                styleButtonTrackColor
                    .getElement()
                    .getStyle()
                    .setProperty("backgroundColor", "#".concat(style.getTrackColor()));
              }
            });
    // Markers
    routeMarkersType = new Menu();
    for (Object[] obj :
        new Object[][] {
          {i18n.noMarkers(), null},
          {i18n.standardMarkers(), PositionIconType.iconArchive},
          {i18n.reducedMarkers(), PositionIconType.dotArchive}
        }) {
      CheckMenuItem item = new CheckMenuItem((String) obj[0]);
      final PositionIconType iconType = (PositionIconType) obj[1];
      item.setGroup("markers");
      item.setChecked(
          iconType == ApplicationContext.getInstance().getUserSettings().getArchiveMarkerType());
      if (item.isChecked()) {
        style.setIconType(iconType);
      }
      item.addSelectionHandler(
          new SelectionHandler<Item>() {
            @Override
            public void onSelection(SelectionEvent<Item> event) {
              style.setIconType(iconType);
              archiveHandler.onChangeArchiveMarkerType(iconType);
            }
          });
      routeMarkersType.add(item);
    }

    devicesTabs =
        new TabPanel(GWT.<TabPanel.TabPanelAppearance>create(BlueTabPanelBottomAppearance.class));
    archivePanels = new HashMap<Long, ArchivePanel>();

    uiBinder.createAndBindUi(this);

    markersMenu.setText(i18n.overlayType(UserSettings.OverlayType.MARKERS));

    // Initialize with current time
    long min = 60 * 1000;
    Date now = new Date();
    Date to = new Date(((now.getTime() + 15 * min) / (15 * min)) * 15 * min);
    Date from = new Date(to.getTime() - 60 * min);
    fromDate.setValue(from);
    fromTime.setValue(from);
    toDate.setValue(to);
    toTime.setValue(to);
  }
Beispiel #5
0
  public LogTextPanel(
      final String debugId, final TabItemConfig config, final LogTabPanel logTabPanel) {

    this.debugId = debugId;

    setHeaderVisible(false);

    setCollapsible(false);

    setContextMenu(contextMenu);

    stop =
        new MenuItem(
            "停止运行",
            new SelectionHandler<MenuItem>() {

              @Override
              public void onSelection(final SelectionEvent<MenuItem> se) {
                final MessageBox box = new MessageBox("停止调试?", "确定要停止调试么?");
                box.setPredefinedButtons(PredefinedButton.YES, PredefinedButton.NO);
                box.setIcon(MessageBox.ICONS.question());
                box.addHideHandler(
                    new HideHandler() {
                      @Override
                      public void onHide(HideEvent event) {
                        Dialog btn = (Dialog) event.getSource();
                        String choice = btn.getHideButton().getItemId();
                        if (choice.equalsIgnoreCase("yes")) {
                          debugService.cancelDebug(
                              debugId,
                              new AsyncCallback<Void>() {

                                @Override
                                public void onSuccess(Void result) {
                                  se.getSelectedItem().setEnabled(false);
                                }

                                @Override
                                public void onFailure(Throwable caught) {
                                  Window.alert("取消调试失败!\n原因:" + caught);
                                }
                              });
                        }
                      }
                    });
                box.show();
              }
            });

    contextMenu.add(stop);

    html.addStyleName("console-font");
    logTextScrollPanel.setWidget(html);

    this.add(logTextScrollPanel);

    timer =
        new Timer() {
          public void run() {
            final LogTextPanel logTextPanel = LogTextPanel.this;
            debugService.getHistoryModel(
                debugId,
                new AsyncCallback<DebugHistoryModel>() {

                  @Override
                  public void onSuccess(DebugHistoryModel result) {
                    // 刷新日志
                    String[] lines = result.getLog().split("\n");
                    StringBuffer sb = new StringBuffer();
                    for (String line : lines) {
                      for (long i = 1; i < 9; i++) {
                        line = line.replace((char) ('\u0000' + i), (char) ('\u245f' + i));
                      }
                      String job = ToolUtil.extractJobId(line);
                      if (job != null) {
                        String newline =
                            line.replaceFirst(
                                job,
                                "<a target='_blank' href='http://10.249.54.103:50030/jobdetails.jsp?jobid="
                                    + job
                                    + "&refresh=30'>"
                                    + job
                                    + "</a>");
                        sb.append(newline + "<br/>");
                      } else {
                        sb.append(line + "<br/>");
                      }
                    }
                    // 不在底部的时候不自动滚动
                    boolean needScroll =
                        (logTextScrollPanel.getMaximumVerticalScrollPosition()
                                - logTextScrollPanel.getVerticalScrollPosition()
                            < 14);
                    // 判断后才把新内容填进去
                    html.setHTML(sb.toString());
                    if (needScroll) {
                      logTextScrollPanel.scrollToBottom();
                    }

                    // 更新状态
                    if (result.getStatus().equals(DebugHistoryModel.Status.SUCCESS)) {
                      config.setIcon(Images.getImageResources().traffic_green());
                      stop.setEnabled(false);
                      isRunning = false;
                      cancel();
                    } else if (result.getStatus().equals(DebugHistoryModel.Status.FAILED)) {
                      config.setIcon(Images.getImageResources().traffic_red());
                      stop.setEnabled(false);
                      isRunning = false;
                      cancel();
                    } else {
                      config.setIcon(Images.getImageResources().processingIcon());
                      stop.setEnabled(true);
                      isRunning = true;
                    }
                    logTabPanel.update(logTextPanel, config);
                  }

                  @Override
                  public void onFailure(Throwable caught) {
                    // 忽略日志刷新失败
                  }
                });
          }
        };
    timer.scheduleRepeating(2000);
  }
  /**
   * Class constructor
   *
   * @param binder
   */
  @Inject
  public CurriculumNodeTreeView(final Binder binder) {

    // tree comes pre sorted from server
    tree =
        new Tree<CurriculumNodeProxy, String>(
            store,
            new ValueProvider<CurriculumNodeProxy, String>() {
              @Override
              public String getValue(CurriculumNodeProxy object) {
                return object.getName();
              }

              @Override
              public void setValue(CurriculumNodeProxy object, String value) {}

              @Override
              public String getPath() {
                return "name";
              }
            });
    tree.setIconProvider(
        new IconProvider<CurriculumNodeProxy>() {
          @Override
          public ImageResource getIcon(CurriculumNodeProxy model) {
            CurriculumNodeTypeIcon icon = new CurriculumNodeTypeIcon(model.getType());
            return icon.getImageResource();
          }
        });

    // checkbox tree configuration
    tree.setCheckable(true);
    tree.setCheckNodes(CheckNodes.BOTH);
    tree.setCheckStyle(CheckCascade.NONE);
    tree.setAutoLoad(true);

    // expanding context menu in tree, events should be handled in presenter
    // (UI-Handler Class)
    Menu contextMenu = new Menu();
    MenuItem expandAll = new MenuItem(COCerResources.TEXT.expandAll());
    expandAll.setIcon(COCerResources.IMAGES.arrow_out());
    expandAll.addSelectionHandler(
        new SelectionHandler<Item>() {
          @Override
          public void onSelection(SelectionEvent<Item> event) {
            if (tree.getSelectionModel().getSelectedItem().equals(store.getRootItems().get(0))) {
              tree.expandAll();
            } else {
              for (CurriculumNodeProxy node : tree.getSelectionModel().getSelectedItems()) {
                tree.setExpanded(node, true, true);
              }
            }
          }
        });
    contextMenu.add(expandAll);
    MenuItem collapseAll = new MenuItem(COCerResources.TEXT.collapseAll());
    collapseAll.setIcon(COCerResources.IMAGES.arrow_in());
    collapseAll.addSelectionHandler(
        new SelectionHandler<Item>() {
          @Override
          public void onSelection(SelectionEvent<Item> event) {
            if (tree.getSelectionModel().getSelectedItem().equals(store.getRootItems().get(0))) {
              tree.collapseAll();
            } else {
              for (CurriculumNodeProxy node : tree.getSelectionModel().getSelectedItems()) {
                tree.setExpanded(node, false, true);
              }
            }
          }
        });
    contextMenu.add(collapseAll);
    tree.setContextMenu(contextMenu);

    widget = binder.createAndBindUi(this);

    panel.add(tree);
  }