Exemplo n.º 1
0
  private Composite createWinStatusBar(Composite composite) {
    Composite winStatusbar = new Composite(composite, SWT.NONE);
    winStatusbar.setLayoutData(new RowData(850, 25));

    Label smlIconLabel = new Label(winStatusbar, SWT.NONE);
    smlIconLabel.setBounds(565, 7, 16, 16);
    smlIconLabel.setImage(SWTResourceManager.getImage(getClass(), "/res/icon_sml.png"));

    CLabel smlLabel = new CLabel(winStatusbar, SWT.NONE);
    smlLabel.setForeground(SWTResourceManager.getColor(SWT.COLOR_TITLE_BACKGROUND_GRADIENT));
    smlLabel.setBounds(585, 5, 67, 20);
    smlLabel.setText("软件小助手");

    Label settingIconLabel = new Label(winStatusbar, SWT.NONE);
    settingIconLabel.setBounds(655, 7, 16, 16);
    settingIconLabel.setImage(SWTResourceManager.getImage(getClass(), "/res/setting.png"));

    CLabel lsettingLbel = new CLabel(winStatusbar, SWT.NONE);
    lsettingLbel.setForeground(SWTResourceManager.getColor(SWT.COLOR_TITLE_BACKGROUND_GRADIENT));
    lsettingLbel.setBounds(668, 5, 30, 20);
    lsettingLbel.setText("设置");

    Label downloadMgrIconLabel = new Label(winStatusbar, SWT.NONE);
    downloadMgrIconLabel.setBounds(705, 5, 16, 16);
    downloadMgrIconLabel.setImage(SWTResourceManager.getImage(getClass(), "/res/downloadMgr.png"));

    CLabel downloadMgrLabel = new CLabel(winStatusbar, SWT.NONE);
    downloadMgrLabel.setForeground(
        SWTResourceManager.getColor(SWT.COLOR_TITLE_BACKGROUND_GRADIENT));
    downloadMgrLabel.setBounds(725, 5, 117, 20);
    downloadMgrLabel.setText("已下载软件共 10 款");

    return winStatusbar;
  }
Exemplo n.º 2
0
 private void statusMessage(boolean error, String message) {
   fStatusLabel.setText(message);
   if (error) {
     fStatusLabel.setForeground(JFaceColors.getErrorText(fStatusLabel.getDisplay()));
   } else {
     fStatusLabel.setForeground(null);
   }
 }
  /**
   * Constructor for TabbedPropertyTitle.
   *
   * @param parent the parent composite.
   * @param factory the widget factory for the tabbed property sheet
   */
  public TabbedPropertyTitle(Composite parent, TabbedPropertySheetWidgetFactory factory) {
    super(parent, SWT.NO_FOCUS);
    this.factory = factory;

    // RAP not suppported
    //		this.addPaintListener(new PaintListener() {
    //
    //			public void paintControl(PaintEvent e) {
    //				if (image == null && (text == null || text.equals(BLANK))) {
    //					label.setVisible(false);
    //				} else {
    //					label.setVisible(true);
    //					drawTitleBackground(e);
    //				}
    //			}
    //		});
    // /RAP

    factory.getColors().initializeSectionToolBarColors();
    setBackground(factory.getColors().getBackground());
    setForeground(factory.getColors().getForeground());

    FormLayout layout = new FormLayout();
    layout.marginWidth = 1;
    layout.marginHeight = 2;
    setLayout(layout);

    Font font;
    if (!JFaceResources.getFontRegistry().hasValueFor(TITLE_FONT)) {
      FontData[] fontData =
          JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT).getFontData();
      /* title font is 2pt larger than that used in the tabs. */
      fontData[0].setHeight(fontData[0].getHeight() + 2);
      JFaceResources.getFontRegistry().put(TITLE_FONT, fontData);
    }
    font = JFaceResources.getFont(TITLE_FONT);

    label = factory.createCLabel(this, BLANK);
    //		label.setBackground(new Color[] {
    //				factory.getColors().getColor(IFormColors.H_GRADIENT_END),
    //				factory.getColors().getColor(IFormColors.H_GRADIENT_START) },
    //				new int[] { 100 }, true);
    label.setFont(font);
    label.setForeground(factory.getColors().getColor(IFormColors.TITLE));
    FormData data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.top = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    data.bottom = new FormAttachment(100, 0);
    label.setLayoutData(data);

    /*
     * setImage(PlatformUI.getWorkbench().getSharedImages().getImage(
     * ISharedImages.IMG_OBJ_ELEMENT));
     */
  }
  /**
   * Updates the message label widget.
   *
   * @since 3.0
   */
  private void updateMessageLabel() {
    if (fLabel != null && !fLabel.isDisposed()) {
      Display display = fLabel.getDisplay();
      if ((fErrorText != null && fErrorText.length() > 0) || fErrorImage != null) {
        String escapedErrorText = escape(fErrorText);
        fLabel.setForeground(JFaceColors.getErrorText(display));
        fLabel.setText(escapedErrorText);
        fLabel.setImage(fErrorImage);
        if (fToolTipText != null) fLabel.setToolTipText(escape(fToolTipText));
        else if (fErrorText.length() > fWidthInChars) fLabel.setToolTipText(escapedErrorText);
        else fLabel.setToolTipText(null);

      } else {
        String escapedText = escape(fText);
        fLabel.setForeground(fLabel.getParent().getForeground());
        fLabel.setText(escapedText);
        fLabel.setImage(fImage);
        if (fToolTipText != null) fLabel.setToolTipText(escape(fToolTipText));
        else if (fText != null && fText.length() > fWidthInChars)
          fLabel.setToolTipText(escapedText);
        else fLabel.setToolTipText(null);
      }
    }
  }
  /** Create contents of the dialog. */
  private void createContents() {
    shell = new Shell(getParent(), getStyle());
    shell.setSize(624, 617);
    shell.setText(getText());
    GridLayout gl_shell = new GridLayout(1, false);
    gl_shell.horizontalSpacing = 0;
    gl_shell.marginHeight = 0;
    gl_shell.verticalSpacing = 0;
    gl_shell.marginWidth = 0;
    shell.setLayout(gl_shell);
    shell.setBackground(ColorRepository.getColor(ColorRepository.BG_CONTENTS));
    //		shell.setBackgroundMode(SWT.TRANSPARENT);

    CLabel lblTitle = new CLabel(shell, SWT.CENTER);
    lblTitle.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
    GridData gd_lblTitle = new GridData(SWT.FILL, SWT.CENTER, true, false);
    gd_lblTitle.heightHint = 44;
    lblTitle.setLayoutData(gd_lblTitle);
    lblTitle.setFont(titleFont);
    lblTitle.setBackgroundImage(ImageRepository.getImage(ImageRepository.POPUP_TITLE_BG));
    lblTitle.setText("2차 계량 - 대상 차량 선택");

    Composite compContents = new Composite(shell, SWT.NONE);
    compContents.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
    compContents.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    GridLayout gl_compContents = new GridLayout(1, false);
    gl_compContents.marginTop = 10;
    gl_compContents.marginRight = 10;
    gl_compContents.marginLeft = 10;
    gl_compContents.marginBottom = 10;
    gl_compContents.verticalSpacing = 0;
    gl_compContents.marginWidth = 0;
    gl_compContents.marginHeight = 0;
    compContents.setLayout(gl_compContents);

    compCenter = new Composite(compContents, SWT.BORDER);
    compCenter.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));
    compCenter.setLayout(new GridLayout(2, false));

    car = new CarComposite(compCenter, SWT.NONE);
    car.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusLost(FocusEvent e) {
            filter();
          }
        });
    car.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
    car.setFont(defaultFont);
    car.setTitle("차량 번호: ");
    car.addFocusListener(new HelpAdapter("차량번호를 입력하거나 목록에서 선택 후 Enter."));

    Button btnSearch = new Button(compCenter, SWT.NONE);
    btnSearch.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            select();
          }
        });
    btnSearch.setFont(btnFont);
    btnSearch.setText(" 조 회 ");

    initGird(compContents);

    Composite btn = new Composite(shell, SWT.NONE);
    btn.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
    btn.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    btn.setBackgroundMode(SWT.INHERIT_FORCE);
    if (user.hasAuth(DTSConstants.AUTH_DEL_FST)) {
      btn.setLayout(new GridLayout(4, false));
    } else {
      btn.setLayout(new GridLayout(3, false));
    }

    Button btnSave = new Button(btn, SWT.NONE);
    GridData gd_btnSave = new GridData(SWT.RIGHT, SWT.FILL, true, false);
    gd_btnSave.heightHint = 36;
    gd_btnSave.widthHint = 130;
    btnSave.setLayoutData(gd_btnSave);
    btnSave.setFont(btnFont);
    btnSave.setText("2차 계량");
    btnSave.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            onClickOK();
          }
        });

    Button btnPrint = new Button(btn, SWT.NONE);
    GridData gd_btnPrint = new GridData(SWT.RIGHT, SWT.FILL, true, false);
    gd_btnPrint.heightHint = 36;
    gd_btnPrint.widthHint = 130;
    btnPrint.setLayoutData(gd_btnPrint);
    btnPrint.setFont(btnFont);
    btnPrint.setText("전표 출력");
    btnPrint.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            Grid g = gridViewer.getGrid();
            if (g.getSelectionIndex() == -1) {
              MessageDialog.openInformation(
                  shell, "데이터 선택 필요", "선택된 데이터가 없습니다. \n\n목록에서 선택 후 작업하세요.");
              return;
            } else {
              if (listData != null && listData.length > g.getSelectionIndex()) {
                TsWgtInfDTO dto = listData[g.getSelectionIndex()];

                PrintUtil.print(dto, preferences.getInt(DTSPreConstants.GN_PRINT_COUNT));
              }
            }
          }
        });

    if (user.hasAuth(DTSConstants.AUTH_DEL_FST)) {
      Button btnDelete = new Button(btn, SWT.NONE);
      GridData gd_btnDelete = new GridData(SWT.CENTER, SWT.FILL, true, false);
      gd_btnDelete.heightHint = 36;
      gd_btnDelete.widthHint = 130;
      btnDelete.setLayoutData(gd_btnDelete);
      btnDelete.setFont(btnFont);
      btnDelete.setText("삭 제");
      btnDelete.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              onClickDelete();
            }
          });
    }
    Button btnCancel = new Button(btn, SWT.NONE);
    btnCancel.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            shell.close();
          }
        });
    GridData gd_btnCancel = new GridData(SWT.LEFT, SWT.FILL, true, false);
    gd_btnCancel.heightHint = 36;
    gd_btnCancel.widthHint = 130;
    btnCancel.setLayoutData(gd_btnCancel);
    btnCancel.setFont(btnFont);
    btnCancel.setText("취  소");

    lblHelp = new CLabel(shell, SWT.LEFT);
    lblHelp.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
    GridData gd_lblHelp = new GridData(SWT.FILL, SWT.CENTER, true, false);
    gd_lblHelp.heightHint = 25;
    lblHelp.setLayoutData(gd_lblHelp);
    lblHelp.setText("도움말:");
    lblHelp.setFont(helpFont);
    lblHelp.setBackgroundImage(ImageRepository.getImage(ImageRepository.POPUP_HELP_BG));

    shell.addListener(
        SWT.Traverse,
        new Listener() {
          public void handleEvent(Event event) {
            if (event.detail == SWT.TRAVERSE_ESCAPE) {
              event.doit = false;
            }
          }
        });
  } // createContents
 public void setErrorMessage(String text) {
   if (dragHere != null) {
     dragHere.setForeground(new Color(null, 255, 0, 0));
     dragHere.setText(text);
   }
 }
 public void setMessage(String text) {
   if (dragHere != null) { // before initialize
     dragHere.setForeground(new Color(null, 64, 255, 64));
     dragHere.setText(text);
   }
 }
  /** Create the Panel for resolving sql symbols */
  private void createResolveSqlPanel(Composite parent) {
    Group newGroup = WidgetFactory.createGroup(parent, RESOLVE_SQL_GROUP_NAME);
    GridLayout gridLayout = new GridLayout();
    newGroup.setLayout(gridLayout);
    gridLayout.numColumns = 3;
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    gridLayout.marginLeft = 5;
    gridLayout.marginBottom = 5;
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    newGroup.setLayoutData(gridData);
    newGroup.setText(SQL_SYMBOL_TXT);
    // SQL Symbol Label
    // --------------------------------------
    sqlSymbolLabel =
        WidgetFactory.createLabel(newGroup, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); // $NON-NLS-1$
    GridData gdSSL =
        new GridData(
            GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_FILL, false, false, 3, 1);
    sqlSymbolLabel.setLayoutData(gdSSL);
    sqlSymbolLabel.setForeground(getDisplay().getSystemColor(SWT.COLOR_BLUE));

    // Symbol RuntimeType Label
    // --------------------------------------
    Label rtTypeLabel = WidgetFactory.createLabel(newGroup, RUNTIME_TYPE_TXT);
    GridData gdRT =
        new GridData(
            GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_FILL, false, false, 2, 1);
    rtTypeLabel.setLayoutData(gdRT);
    // WidgetFactory.createLabel(newGroup, "");

    Binding binding = bindingList.get(0);
    Object symbol = binding.getCurrentSymbol();
    String text = getLabelText(symbol);
    symbolRuntimeTypeLabel =
        WidgetFactory.createLabel(
            newGroup, text, GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.GRAB_HORIZONTAL);

    // Available Conversion Title Label
    // --------------------------------------
    Label cvLabel =
        WidgetFactory.createLabel(
            newGroup, GridData.HORIZONTAL_ALIGN_BEGINNING, CONVERTED_SYMBOL_TXT);
    GridData gdCV =
        new GridData(
            GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_FILL, false, false, 2, 1);
    cvLabel.setLayoutData(gdCV);

    // Available Sql Conversion Text
    // --------------------------------------

    String convertedSymbol = binding.getSqlConversionText();
    int lossOfPrecIndex = convertedSymbol.indexOf('\n');
    String warningText = CoreStringUtil.Constants.EMPTY_STRING;
    if (lossOfPrecIndex > -1) {
      warningText = convertedSymbol.substring(lossOfPrecIndex + 1, convertedSymbol.length());
      convertedSymbol = convertedSymbol.substring(0, lossOfPrecIndex);
    }

    symbolConversionLabel =
        WidgetFactory.createLabel(newGroup, convertedSymbol, GridData.FILL_BOTH);

    symbolWarningLabel = WidgetFactory.createLabel(newGroup, warningText, GridData.FILL_BOTH);
    GridData gdWarning =
        new GridData(
            GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_FILL, false, false, 3, 1);
    symbolWarningLabel.setLayoutData(gdWarning);

    // Conversion Buttons Panel
    // --------------------------------------

    // Create the changeSelectedSql Button
    this.convertSelectedSqlButton =
        WidgetFactory.createButton(
            newGroup, CONVERT_SELECTED_SQL_BUTTON, GridData.HORIZONTAL_ALIGN_BEGINNING);
    this.convertSelectedSqlButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(final SelectionEvent event) {
            convertSelectedSqlPressed();
          }
        });

    // Create the changeAllSql Button
    this.convertAllSqlButton =
        WidgetFactory.createButton(
            newGroup, CONVERT_ALL_SQL_BUTTON, GridData.HORIZONTAL_ALIGN_BEGINNING);
    this.convertAllSqlButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(final SelectionEvent event) {
            convertAllSqlPressed();
          }
        });
    sqlGroup = newGroup;
  }
  private void createResolveAttributePanel(Composite parent) {
    if (this.targetLocked) {
      attrGroup = WidgetFactory.createGroup(parent, RESOLVE_ATTR_GROUP_LOCKED_NAME);
    } else {
      attrGroup = WidgetFactory.createGroup(parent, RESOLVE_ATTR_GROUP_NAME);
    }
    GridLayout gridLayout = new GridLayout();
    attrGroup.setLayout(gridLayout);
    gridLayout.numColumns = 4;
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    gridLayout.marginLeft = 5;
    gridLayout.marginBottom = 5;
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    attrGroup.setLayoutData(gridData);

    Binding binding = bindingList.get(0);
    Object attr = binding.getAttribute();
    // Attribute Datatype Label
    EObject datatype = null;
    attr = binding.getAttribute();
    if (TransformationHelper.isSqlColumn(attr)) {
      datatype = TransformationHelper.getSqlColumnDatatype((EObject) attr);
    }
    String datatypeText = getDatatypeText(datatype);
    Image datatypeImage = getDatatypeImage(datatype);

    attrGroup.setText(VIRTUAL_TARGET_ATTRIBUTE_TXT);

    // --------------------------------------
    // SQL Symbol Label
    // --------------------------------------
    attributeLabel =
        WidgetFactory.createLabel(attrGroup, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); // $NON-NLS-1$
    GridData attrGD =
        new GridData(
            GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_FILL, false, false, 4, 1);
    attributeLabel.setLayoutData(attrGD);
    attributeLabel.setForeground(getDisplay().getSystemColor(SWT.COLOR_BLUE));

    Label rtTypeLabel = WidgetFactory.createLabel(attrGroup, RUNTIME_TYPE_TXT);
    GridData gdRT =
        new GridData(
            GridData.HORIZONTAL_ALIGN_BEGINNING,
            GridData.VERTICAL_ALIGN_BEGINNING,
            false,
            false,
            2,
            1);
    rtTypeLabel.setLayoutData(gdRT);
    WidgetFactory.createLabel(attrGroup, CoreStringUtil.Constants.EMPTY_STRING);

    // --------------------------------------
    // Attribute RuntimeType Label
    // --------------------------------------
    attrRuntimeTypeLabel =
        WidgetFactory.createLabel(
            attrGroup,
            datatypeText,
            datatypeImage,
            GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.GRAB_HORIZONTAL);

    // --------------------------------------
    // Attribute Type Chooser Panel
    // --------------------------------------
    // Create the changeSelectedAttribute Button
    this.convertSelectedAttrButton =
        WidgetFactory.createButton(
            attrGroup, CONVERT_SELECTED_ATTR_BUTTON, GridData.HORIZONTAL_ALIGN_BEGINNING);
    this.convertSelectedAttrButton.setEnabled(false);
    this.convertSelectedAttrButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(final SelectionEvent event) {
            convertSelectedAttrPressed();
          }
        });

    // Create the changeAllAttributes Button
    this.convertAllAttrsButton =
        WidgetFactory.createButton(
            attrGroup, CONVERT_ALL_ATTR_BUTTON, GridData.HORIZONTAL_ALIGN_BEGINNING);
    this.convertAllAttrsButton.setEnabled(false);
    this.convertAllAttrsButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(final SelectionEvent event) {
            convertAllAttrsPressed();
          }
        });

    // Create the showDatatypeDialog Button
    this.showDatatypeDialogButton =
        WidgetFactory.createButton(
            attrGroup, "Change", GridData.HORIZONTAL_ALIGN_END); // $NON-NLS-1$
    this.showDatatypeDialogButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(final SelectionEvent event) {
            showDatatypeDialogPressed();
          }
        });

    attrDatatypeLabel =
        WidgetFactory.createLabel(
            attrGroup,
            "xxxxxxxxxxxxxxxxxxxxxxx",
            datatypeImage, //$NON-NLS-1$
            GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.GRAB_HORIZONTAL);
    if (this.targetLocked) {
      this.showDatatypeDialogButton.setEnabled(false);
    } else {
      this.showDatatypeDialogButton.setEnabled(true);
    }
  }
  @Override
  public void createPartControl(Composite parent) {

    final Composite main = new Composite(parent, SWT.NONE);
    main.setLayout(new GridLayout());
    GridUtils.removeMargins(main);

    final Composite tools = new Composite(main, SWT.RIGHT);
    tools.setLayout(new GridLayout(2, false));
    GridUtils.removeMargins(tools);
    tools.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    this.messageLabel = new CLabel(tools, SWT.NONE);
    final GridData gridData = new GridData(SWT.LEFT, SWT.CENTER, false, false);
    gridData.widthHint = 230;
    messageLabel.setLayoutData(gridData);
    messageLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GRAY));
    messageLabel.setToolTipText(
        "Insert variables to the template xml on the right,\nthis will be replaced and sent to EDNA when the workflow is run.");

    ToolBarManager toolMan = new ToolBarManager(SWT.FLAT | SWT.LEFT);
    final ToolBar toolBar = toolMan.createControl(tools);
    toolBar.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
    EdnaActorActions.createInputActions(toolMan);

    final SashForm sash = new SashForm(main, SWT.HORIZONTAL);
    sash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    this.viewer =
        new TableViewer(
            sash, SWT.FULL_SELECTION | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    createColumns(viewer);
    viewer.getTable().setLinesVisible(true);
    viewer.getTable().setHeaderVisible(true);

    final Composite right = new Composite(sash, SWT.NONE);
    right.setLayout(new FillLayout());
    super.createPartControl(right);

    sash.setWeights(new int[] {20, 80});

    // Attached a painter to highlight the replacements
    final VariableCharacterMatcher matcher =
        new VariableCharacterMatcher(((SourceViewer) getSourceViewer()));
    final VariablePainter painter = new VariablePainter(getSourceViewer(), matcher);
    ((SourceViewer) getSourceViewer()).addPainter(painter);
    viewer.addSelectionChangedListener(matcher);
    viewer.addDoubleClickListener(
        new IDoubleClickListener() {
          @Override
          public void doubleClick(DoubleClickEvent event) {
            doInsert();
          }
        });
    ((SourceViewer) getSourceViewer())
        .addSelectionChangedListener(
            new ISelectionChangedListener() {
              @Override
              public void selectionChanged(SelectionChangedEvent event) {
                final ISelection sel = event.getSelection();
                if (sel instanceof TextSelection) {
                  XMLSubstitutionEditor.this.currentSelectedText = (TextSelection) sel;
                  updateMessageLabel();
                  return;
                }
                XMLSubstitutionEditor.this.currentSelectedText = null;
                updateMessageLabel();
              }
            });

    toolMan.update(true);
    setWritable(true);
    getSite().setSelectionProvider(viewer);
    createUndoRedoActions();
    createRightClickMenu();
  }
Exemplo n.º 11
0
  private Composite createWinTitle(Composite composite) {
    Composite winTitle = new Composite(composite, SWT.NONE);
    winTitle.setLayoutData(new RowData(850, 25));

    SystemButton menuBtn =
        new SystemButton(
            winTitle,
            SWT.NONE,
            "/res/sysbtn_menu.png",
            4,
            "菜单",
            this,
            new Listener() {

              @Override
              public void handleEvent(Event e) {
                int x = e.getBounds().x;
                int y = e.getBounds().y;
                if (x < 0 || y < 0) return;
                ((Composite) (e.widget)).getMenu().setVisible(true);
              }
            });
    menuBtn.setLocation(769, 0);
    Menu menu = new Menu(menuBtn);
    menuBtn.setMenu(menu);
    MenuItem mntmCaidan = new MenuItem(menu, SWT.NONE);
    mntmCaidan.setText("设置");

    MenuItem menuItem = new MenuItem(menu, SWT.NONE);
    menuItem.setText("\u65B0\u7248\u529F\u80FD");

    MenuItem menuItem_1 = new MenuItem(menu, SWT.NONE);
    menuItem_1.setText("\u5B98\u65B9\u5FAE\u535A");

    MenuItem menuItem_2 = new MenuItem(menu, SWT.NONE);
    menuItem_2.setText("\u95EE\u9898\u53CD\u9988\u4E0E\u5EFA\u8BAE");

    MenuItem menuItem_3 = new MenuItem(menu, SWT.NONE);
    menuItem_3.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {}
        });
    menuItem_3.setText("\u7528\u6237\u9690\u79C1\u4FDD\u62A4\u653F\u7B56");

    MenuItem menuItem_4 = new MenuItem(menu, SWT.NONE);
    menuItem_4.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            MessageBox mb = new MessageBox(shell, SWT.ABORT);
            mb.setMessage("开源中国 @xwalker QQ:909854136");
            mb.setText("关于");
            mb.open();
          }
        });
    menuItem_4.setText("\u5173\u4E8E\u6211\u4EEC");

    SystemButton minBtn =
        new SystemButton(
            winTitle,
            SWT.NONE,
            "/res/sysbtn_min.png",
            4,
            "最小化",
            this,
            new Listener() {

              @Override
              public void handleEvent(Event event) {
                shell.setMinimized(true);
              }
            });
    minBtn.setLocation(796, 0);

    SystemButton closeBtn =
        new SystemButton(
            winTitle,
            SWT.NONE,
            "/res/sysbtn_close.png",
            4,
            "关闭",
            this,
            new Listener() {

              @Override
              public void handleEvent(Event event) {
                MessageBox mb = new MessageBox(shell, SWT.OK | SWT.CANCEL);
                mb.setMessage("确定退出?");
                mb.setText("确定");
                if (mb.open() == SWT.OK) {
                  shell.close();
                  shell.dispose();
                }
              }
            });
    closeBtn.setLocation(823, 0);

    CLabel lblJava = new CLabel(winTitle, SWT.NONE);
    lblJava.setFont(SWTResourceManager.getFont("微软雅黑", 9, SWT.BOLD));
    lblJava.setForeground(SWTResourceManager.getColor(SWT.COLOR_TITLE_BACKGROUND_GRADIENT));
    lblJava.setBounds(5, 0, 309, 23);
    lblJava.setText("Java\u684C\u9762\u7A0B\u5E8F \u4EFF360\u8F6F\u4EF6\u7BA1\u5BB6 QQ:909854136");

    return winTitle;
  }