/**
   * 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));
     */
  }
 /**
  * Creates a new <code>CLabel</code> that will wrap at the specified width and has the specified
  * image
  *
  * @param parent the parent to add this label to
  * @param text the text for the label
  * @param image the image for the label
  * @param hspan the h span to take up in the parent
  * @param wrapwidth the with to wrap at
  * @return a new <code>CLabel</code>
  * @since 3.3
  */
 public static CLabel createWrapCLabel(
     Composite parent, String text, Image image, int hspan, int wrapwidth) {
   CLabel label = new CLabel(parent, SWT.NONE | SWT.WRAP);
   label.setFont(parent.getFont());
   if (text != null) {
     label.setText(text);
   }
   if (image != null) {
     label.setImage(image);
   }
   GridData gd = new GridData(GridData.FILL_HORIZONTAL);
   gd.horizontalSpan = hspan;
   gd.widthHint = wrapwidth;
   label.setLayoutData(gd);
   return label;
 }
  /** Set the folder colors and fonts */
  private void setColorsAndFonts() {
    folder.setSelectionForeground(
        theme.getColorRegistry().get(IWorkbenchThemeConstants.ACTIVE_TAB_TEXT_COLOR));
    folder.setForeground(
        theme.getColorRegistry().get(IWorkbenchThemeConstants.INACTIVE_TAB_TEXT_COLOR));

    Color[] colors = new Color[2];
    colors[0] = theme.getColorRegistry().get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START);
    colors[1] = theme.getColorRegistry().get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END);
    colors[0] = theme.getColorRegistry().get(IWorkbenchThemeConstants.ACTIVE_TAB_BG_START);
    colors[1] = theme.getColorRegistry().get(IWorkbenchThemeConstants.ACTIVE_TAB_BG_END);
    folder.setSelectionBackground(
        colors,
        new int[] {theme.getInt(IWorkbenchThemeConstants.ACTIVE_TAB_PERCENT)},
        theme.getBoolean(IWorkbenchThemeConstants.ACTIVE_TAB_VERTICAL));

    folder.setFont(theme.getFontRegistry().get(IWorkbenchThemeConstants.TAB_TEXT_FONT));
    viewMessage.setFont(
        theme.getFontRegistry().get(IWorkbenchThemeConstants.VIEW_MESSAGE_TEXT_FONT));
  }
  /** 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
示例#5
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;
  }
  /**
   * Constructor for TabbedPropertyTitle.
   *
   * @param parent the parent composite.
   * @param factory the widget factory for the tabbed property sheet
   */
  public TabbedPropertyTitle(Composite parent, FormWidgetFactory factory) {
    super(parent, SWT.NONE);
    this.factory = factory;

    bg = factory.getColors().getColor(FormColors.TB_BG);
    gbg = factory.getColors().getColor(FormColors.TB_GBG);
    border = factory.getColors().getColor(FormColors.TB_BORDER);

    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);
            }
          }
        });

    this.addFocusListener(
        new FocusListener() {

          public void focusGained(FocusEvent e) {
            if (toolbar != null) {
              toolbar.setFocus();

            } else getParent().setFocus();
          }

          public void focusLost(FocusEvent e) {
            // TODO Auto-generated method stub

          }
        });

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

    FormLayout layout = new FormLayout();
    layout.marginWidth = ITabbedPropertyConstants.HSPACE + 6;
    layout.marginHeight = 5;
    setLayout(layout);

    label =
        new CLabel(this, SWT.NONE) {

          public Point computeSize(int wHint, int hHint, boolean changed) {
            Point p = super.computeSize(wHint, hHint, changed);
            p.y = p.y + 2;
            return p;
          }
        };
    label.setBackground(parent.getBackground());
    label.setText(BLANK);
    GridLayout gl = new GridLayout();
    gl.marginHeight = 0;
    label.setLayout(gl);

    // resetButton = new Button( label, SWT.FLAT );
    //		resetButton.setText( Messages.getString( "TabbedPropertyTitle.Button.Default.Text" ) );
    // //$NON-NLS-1$
    // GridData gd = new GridData( );
    // gd.grabExcessHorizontalSpace = true;
    // gd.horizontalAlignment = SWT.END;
    // gd.grabExcessVerticalSpace = true;
    // gd.verticalAlignment = SWT.CENTER;
    // resetButton.setLayoutData( gd );
    // resetButton.setVisible( false );
    // resetButton.addSelectionListener( new SelectionAdapter( ) {
    //
    // public void widgetSelected( SelectionEvent e )
    // {
    // Event event = new Event( );
    // event.widget = resetButton;
    // TabbedPropertyTitle.this.notifyListeners( SWT.SELECTED, event );
    // }
    //
    // } );
    //		resetButton.setToolTipText( Messages.getString(
    // "TabbedPropertyTitle.Button.Default.TooltipText" ) ); //$NON-NLS-1$

    label.setBackground(
        new Color[] {
          factory.getColors().getColor(FormColors.TB_BG),
          factory.getColors().getColor(FormColors.TB_GBG)
        },
        new int[] {100},
        true);
    label.setFont(JFaceResources.getBannerFont());
    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));
     */
  }
示例#7
0
  private void addTextPatternControls(Composite group) {
    // grid layout with 2 columns

    // Info text
    Label label = new Label(group, SWT.LEAD);
    label.setText(SearchMessages.SearchPage_containingText_text);
    label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
    label.setFont(group.getFont());

    // Pattern combo
    fPattern = new Combo(group, SWT.SINGLE | SWT.BORDER);
    // Not done here to prevent page from resizing
    // fPattern.setItems(getPreviousSearchPatterns());
    fPattern.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            handleWidgetSelected();
            updateOKStatus();
          }
        });
    // add some listeners for regex syntax checking
    fPattern.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(ModifyEvent e) {
            updateOKStatus();
          }
        });
    fPattern.setFont(group.getFont());
    GridData data = new GridData(GridData.FILL, GridData.FILL, true, false, 1, 1);
    data.widthHint = convertWidthInCharsToPixels(50);
    fPattern.setLayoutData(data);

    ComboContentAdapter contentAdapter = new ComboContentAdapter();
    FindReplaceDocumentAdapterContentProposalProvider findProposer =
        new FindReplaceDocumentAdapterContentProposalProvider(true);
    fPatterFieldContentAssist =
        new ContentAssistCommandAdapter(
            fPattern,
            contentAdapter,
            findProposer,
            ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS,
            new char[0],
            true);
    fPatterFieldContentAssist.setEnabled(fIsRegExSearch);

    fIsCaseSensitiveCheckbox = new Button(group, SWT.CHECK);
    fIsCaseSensitiveCheckbox.setText(SearchMessages.SearchPage_caseSensitive);
    fIsCaseSensitiveCheckbox.setSelection(fIsCaseSensitive);
    fIsCaseSensitiveCheckbox.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            fIsCaseSensitive = fIsCaseSensitiveCheckbox.getSelection();
          }
        });
    fIsCaseSensitiveCheckbox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    fIsCaseSensitiveCheckbox.setFont(group.getFont());

    // Text line which explains the special characters
    fStatusLabel = new CLabel(group, SWT.LEAD);
    fStatusLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    fStatusLabel.setFont(group.getFont());
    fStatusLabel.setAlignment(SWT.LEFT);
    fStatusLabel.setText(SearchMessages.SearchPage_containingText_hint);

    // RegEx checkbox
    fIsRegExCheckbox = new Button(group, SWT.CHECK);
    fIsRegExCheckbox.setText(SearchMessages.SearchPage_regularExpression);
    fIsRegExCheckbox.setSelection(fIsRegExSearch);

    fIsRegExCheckbox.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            fIsRegExSearch = fIsRegExCheckbox.getSelection();
            updateOKStatus();

            writeConfiguration();
            fPatterFieldContentAssist.setEnabled(fIsRegExSearch);
          }
        });
    fIsRegExCheckbox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    fIsRegExCheckbox.setFont(group.getFont());
  }