/**
   * Installs the given color in the preference store and optionally the color registry.
   *
   * @param definition the color definition
   * @param theme the theme defining the color
   * @param store the preference store from which to set and obtain color data
   * @param setInRegistry whether the color should be put into the registry
   */
  private static void installColor(
      ColorDefinition definition, ITheme theme, IPreferenceStore store, boolean setInRegistry) {

    // TODO: store shouldn't be null, should assert instead of checking null all over

    ColorRegistry registry = theme.getColorRegistry();

    String id = definition.getId();
    String key = createPreferenceKey(theme, id);
    RGB prefColor = store != null ? PreferenceConverter.getColor(store, key) : null;
    RGB defaultColor =
        (definition.getValue() != null)
            ? definition.getValue()
            : registry.getRGB(definition.getDefaultsTo());

    if (prefColor == null || prefColor == PreferenceConverter.COLOR_DEFAULT_DEFAULT) {
      prefColor = defaultColor;
    }

    // if the preference value isn't the default then retain that pref value
    RGB colorToUse = !store.isDefault(key) ? prefColor : defaultColor;

    if (setInRegistry) {
      registry.put(id, colorToUse);
    }

    if (store != null) {
      PreferenceConverter.setDefault(store, key, defaultColor);
    }
  }
Example #2
0
 /**
  * Not thread safe, but should only be called from the UI Thread, so it's not really a problem.
  *
  * @param rgb
  * @return The <code>Color</code> instance cached for this rgb value, creating it along the way if
  *     required.
  */
 public static Color getColor(RGB rgb) {
   ColorRegistry r = getDefault().getColorCache();
   String rgbString = StringConverter.asString(rgb);
   if (!r.hasValueFor(rgbString)) {
     r.put(rgbString, rgb);
   }
   return r.get(rgbString);
 }
  @Override
  public void initialize(IWorkbenchConfigurer configurer) {
    //  윈도우 위치와 크기 저장
    configurer.setSaveAndRestore(true);

    // 색상변경
    IThemeManager themeManager = PlatformUI.getWorkbench().getThemeManager();
    ITheme currentTheme = themeManager.getCurrentTheme();
    ColorRegistry colorRegistry = currentTheme.getColorRegistry();
    colorRegistry.put(IWorkbenchThemeConstants.ACTIVE_TAB_BG_START, new RGB(16, 86, 100));
    colorRegistry.put(IWorkbenchThemeConstants.ACTIVE_TAB_BG_END, new RGB(219, 238, 241));
    colorRegistry.put(IWorkbenchThemeConstants.ACTIVE_TAB_TEXT_COLOR, new RGB(0, 0, 255));

    colorRegistry.put(IWorkbenchThemeConstants.ACTIVE_TAB_PERCENT, new RGB(255, 0, 0));

    super.initialize(configurer);
  }
Example #4
0
  public static void registerEditorColors(IPreferenceStore store, RGB foregroundColor) {
    final ColorRegistry colorCache = getDefault().getColorCache();

    for (Keyword token : PreferenceConstants.colorizableTokens) {
      PreferenceConstants.ColorizableToken tokenStyle =
          PreferenceConstants.getColorizableToken(store, token, foregroundColor);
      colorCache.put(tokenStyle.rgb.toString(), tokenStyle.rgb);
    }
  }
 static {
   // initialize colors
   ColorRegistry registry = JFaceResources.getColorRegistry();
   registry.put(KEYWORD_COLOR, new RGB(128, 0, 128));
   registry.put(STRING_COLOR, new RGB(0, 0, 255));
   registry.put(NUMBER_COLOR, new RGB(215, 107, 0));
   registry.put(COMMENT_COLOR, new RGB(0, 128, 0));
   registry.put(DEFAULT_COLOR, new RGB(0, 0, 0));
   registry.put(ANNOTATION_COLOR, new RGB(0, 150, 150));
 }
Example #6
0
 private synchronized void createColorCache() {
   if (colorCache == null) {
     colorCache = new ColorRegistry(getWorkbench().getDisplay());
     colorCache.put("ccw.repl.expressionBackground", new RGB(0xf0, 0xf0, 0xf0));
   }
 }
 /**
  * Adds (or replaces) a color to this color registry under the given symbolic name.
  *
  * <p>A property change event is reported whenever the mapping from a symbolic name to a color
  * changes. The source of the event is this registry; the property name is the symbolic color
  * name.
  *
  * @param symbolicName the symbolic color name
  * @param colorData an <code>RGB</code> object
  */
 public void put(String symbolicName, RGB colorData) {
   put(symbolicName, colorData, true);
 }
Example #8
0
  public PlayClient() throws IOException {
    iniSettingFile = new IniFile(INI_SETTING_FILE_NAME);
    iniAppDataFile = new IniFile(INI_APPDATA_FILE_NAME);

    iniSettings =
        new IniSettings(iniSettingFile.getSection(IniSettings.SECTION), new WlanProxyLibrary(this));
    iniUserProfile = new IniUserProfile(iniSettingFile.getSection(IniUserProfile.SECTION));
    iniAppearance = new IniAppearance(iniSettingFile.getSection(IniAppearance.SECTION));
    iniAppData = new IniAppData(iniAppDataFile.getSection(null));

    ArrayList<String> pendingLogs = new ArrayList<String>();

    if (JnetPcapWlanDevice.LIBRARY.isReady()) {
      pendingLogs.add("PcapインストールOK");
    } else {
      pendingLogs.add("Pcapがインストールされていません");
    }
    if (NativeWlanDevice.LIBRARY.isReady()) {
      pendingLogs.add("Windowsワイヤレスネットワーク機能OK");
    } else {
      pendingLogs.add("Windowsワイヤレスネットワーク機能がインストールされていません");
    }

    wlanLibrary = iniSettings.getWlanLibrary();

    ILogger logger =
        new ILogger() {
          @Override
          public void log(String message) {
            getArenaWindow().appendToSystemLog(message, true);
          }
        };
    tcpClient = new AsyncTcpClient(logger, 1000000, 0);
    udpClient = new AsyncUdpClient(logger);

    imageRegistry = new ImageRegistry(SwtUtils.DISPLAY);
    colorRegistry = new ColorRegistry(SwtUtils.DISPLAY);

    clipboard = new Clipboard(SwtUtils.DISPLAY);

    try {
      Image icon16 = new Image(SwtUtils.DISPLAY, new ImageData("icon/blue16.png"));
      Image icon32 = new Image(SwtUtils.DISPLAY, new ImageData("icon/blue32.png"));
      Image icon48 = new Image(SwtUtils.DISPLAY, new ImageData("icon/blue48.png"));
      Image icon96 = new Image(SwtUtils.DISPLAY, new ImageData("icon/blue96.png"));
      imageRegistry.put(ICON_APP16, icon16);
      imageRegistry.put(ICON_APP32, icon32);
      imageRegistry.put(ICON_APP48, icon48);
      imageRegistry.put(ICON_APP96, icon96);

      shellImages = new Image[] {icon16, icon32, icon48, icon96};

      Image toolArena = new Image(SwtUtils.DISPLAY, new ImageData("icon/toolbar/search.png"));
      Image toolRoom = new Image(SwtUtils.DISPLAY, new ImageData("icon/toolbar/lobby4.png"));
      Image toolConfig = new Image(SwtUtils.DISPLAY, new ImageData("icon/toolbar/config.png"));
      Image toolLog = new Image(SwtUtils.DISPLAY, new ImageData("icon/toolbar/log.png"));
      Image toolWiki = new Image(SwtUtils.DISPLAY, new ImageData("icon/toolbar/wiki.png"));
      Image toolExit = new Image(SwtUtils.DISPLAY, new ImageData("icon/toolbar/lobby3.png"));

      imageRegistry.put(ICON_TOOLBAR_ARENA, toolArena);
      imageRegistry.put(ICON_TOOLBAR_ROOM, toolRoom);
      imageRegistry.put(ICON_TOOLBAR_LOG, toolLog);
      imageRegistry.put(ICON_TOOLBAR_WIKI, toolWiki);
      imageRegistry.put(ICON_TOOLBAR_CONFIG, toolConfig);
      imageRegistry.put(ICON_TOOLBAR_EXIT, toolExit);

      Image tabLobby = new Image(SwtUtils.DISPLAY, new ImageData("icon/tab/lobby.png"));
      Image tabLobbyNotify = new Image(SwtUtils.DISPLAY, new ImageData("icon/tab/lobby2.png"));
      Image tabSystem = new Image(SwtUtils.DISPLAY, new ImageData("icon/tab/log.png"));
      Image tabSystemNotify = new Image(SwtUtils.DISPLAY, new ImageData("icon/tab/log2.png"));
      Image tabPm = new Image(SwtUtils.DISPLAY, new ImageData("icon/tab/pm.png"));
      Image tabPmNotify = new Image(SwtUtils.DISPLAY, new ImageData("icon/tab/pm2.png"));
      Image tabCircle = new Image(SwtUtils.DISPLAY, new ImageData("icon/tab/circle.png"));
      Image tabCircleNotify = new Image(SwtUtils.DISPLAY, new ImageData("icon/tab/circle2.png"));

      imageRegistry.put(ICON_TAB_LOBBY, tabLobby);
      imageRegistry.put(ICON_TAB_LOBBY_NOTIFY, tabLobbyNotify);
      imageRegistry.put(ICON_TAB_LOG, tabSystem);
      imageRegistry.put(ICON_TAB_LOG_NOTIFY, tabSystemNotify);
      imageRegistry.put(ICON_TAB_PM, tabPm);
      imageRegistry.put(ICON_TAB_PM_NOTIFY, tabPmNotify);
      imageRegistry.put(ICON_TAB_CIRCLE, tabCircle);
      imageRegistry.put(ICON_TAB_CIRCLE_NOTIFY, tabCircleNotify);
    } catch (SWTException e) {
    }

    colorRegistry.put(COLOR_OK, new RGB(0, 140, 0));
    colorRegistry.put(COLOR_NG, new RGB(200, 0, 0));
    colorRegistry.put(COLOR_APP_NUMBER, new RGB(0, 0, 220));
    colorRegistry.put(COLOR_TAB_NOTIFY, new RGB(0, 0, 220));

    arenaWindow = new ArenaWindow(this);

    try {
      Tray systemTray = SwtUtils.DISPLAY.getSystemTray();
      if (systemTray != null) {
        trayItem = new TrayItem(systemTray, SWT.NONE);
        trayItem.setImage(imageRegistry.get(ICON_APP16));
        trayItem.addListener(
            SWT.Selection,
            new Listener() {
              @Override
              public void handleEvent(Event event) {
                arenaWindow.show();
                if (roomWindow != null) roomWindow.show();
              }
            });

        toolTip = new ToolTip(arenaWindow.getShell(), SWT.BALLOON | SWT.ICON_INFORMATION);
        trayItem.setToolTip(toolTip);
        trayItem.setToolTipText(AppConstants.APP_NAME);

        final Menu menu = new Menu(arenaWindow.getShell());

        MenuItem itemArena = new MenuItem(menu, SWT.PUSH);
        itemArena.setText("アリーナ");
        itemArena.addListener(
            SWT.Selection,
            new Listener() {
              @Override
              public void handleEvent(Event event) {
                getArenaWindow().show();
              }
            });

        MenuItem itemRoom = new MenuItem(menu, SWT.PUSH);
        itemRoom.setText("ルーム");
        itemRoom.addListener(
            SWT.Selection,
            new Listener() {
              @Override
              public void handleEvent(Event event) {
                getRoomWindow().show();
              }
            });

        MenuItem itemShutdown = new MenuItem(menu, SWT.PUSH);
        itemShutdown.setText("アプリを終了");
        itemShutdown.addListener(
            SWT.Selection,
            new Listener() {
              @Override
              public void handleEvent(Event event) {
                isRunning = false;
              }
            });

        trayItem.addMenuDetectListener(
            new MenuDetectListener() {
              @Override
              public void menuDetected(MenuDetectEvent e) {
                menu.setVisible(true);
              }
            });
      }
    } catch (SWTException e) {
    }

    try {
      serverRegistry = new IniPublicServerRegistry();
    } catch (IOException e) {
      serverRegistry = IServerRegistry.NULL;
      arenaWindow.appendToSystemLog(Utility.stackTraceToString(e), true);
    }
    portalServerList = serverRegistry.getPortalRotator();

    String software =
        String.format("%s プレイクライアント バージョン: %s", AppConstants.APP_NAME, AppConstants.VERSION);
    arenaWindow.appendToSystemLog(software, false);
    arenaWindow.appendToSystemLog("プロトコル: " + IProtocol.NUMBER, false);

    for (String log : pendingLogs) {
      arenaWindow.appendToSystemLog(log, false);
    }

    Thread cronThread =
        new Thread(
            new Runnable() {
              @Override
              public void run() {
                try {
                  while (!SwtUtils.DISPLAY.isDisposed()) {
                    arenaWindow.cronJob();
                    if (roomWindow != null) roomWindow.cronJob();

                    Thread.sleep(1000);
                  }
                } catch (InterruptedException e) {
                } catch (SWTException e) {
                }
              }
            },
            "CronThread");
    cronThread.setDaemon(true);
    cronThread.start();

    try {
      IPlugin plugin = (IPlugin) Class.forName(BouyomiChanPlugin.class.getName()).newInstance();
      plugin.initPlugin(this);
      pluginList.add(plugin);
    } catch (InstantiationException e) {
    } catch (IllegalAccessException e) {
    } catch (ClassNotFoundException e) {
    }

    arenaWindow
        .getShell()
        .addShellListener(
            new ShellListener() {
              @Override
              public void shellActivated(ShellEvent e) {}

              @Override
              public void shellIconified(ShellEvent e) {}

              @Override
              public void shellDeiconified(ShellEvent e) {}

              @Override
              public void shellDeactivated(ShellEvent e) {}

              @Override
              public void shellClosed(ShellEvent e) {
                if (roomWindow == null || !roomWindow.getShell().getVisible()) {
                  checkApplicationShutdown(arenaWindow.getShell(), e);
                } else {
                  e.doit = false;
                  arenaWindow.hide();
                }
              }
            });

    if (Utility.isEmpty(iniUserProfile.getUserName())) {
      TextDialog dialog =
          new TextDialog(
              null,
              AppConstants.APP_NAME + " - ユーザー名が設定されていません",
              "ユーザー名を入力してください",
              null,
              300,
              SWT.NONE);
      switch (dialog.open()) {
        case IDialogConstants.OK_ID:
          iniUserProfile.setUserName(dialog.getUserInput());
          break;
        default:
          iniUserProfile.setUserName("未設定");
      }
    }

    if (iniSettings.isStartupWindowArena()) {
      arenaWindow.show();
    } else {
      getRoomWindow().show();
    }
  }