protected void layout() {
    Rectangle parentArea = this.composite.getClientArea();
    int width = parentArea.width;
    int height = parentArea.height;

    Rectangle sashBounds = sash.getBounds();

    resultText.setBounds(0, 0, width, sashBounds.y);
    userText.setBounds(0, sashBounds.y + 3, width, height - sashBounds.y - 3);
    sash.setBounds(0, sashBounds.y, width, 3);
  }
  protected void resized() {
    Rectangle parentArea = this.composite.getClientArea();
    int width = parentArea.width;
    int height = parentArea.height;

    int userTextHeight = (int) (height * (1 - defaultRatio));
    if (userTextHeight < 25) userTextHeight = 25;

    resultText.setBounds(0, 0, width, height - userTextHeight - 3);
    userText.setBounds(0, height - userTextHeight, width, userTextHeight);
    sash.setBounds(0, height - userTextHeight - 3, width, 3);
  }
Example #3
0
  private void updateSizeAndLocations() {
    if (busyLabel == null || busyLabel.isDisposed()) {
      return;
    }

    Point leftToolBarSize = new Point(0, 0);
    if (leftToolBar != null && !leftToolBar.isDisposed()) {
      // bottom align tool bar in title region
      leftToolBarSize = leftToolBar.getSize();
      int y = leftToolBar.getParent().getSize().y - leftToolBarSize.y - 2;
      if (!hasLeftToolBar()) {
        // hide tool bar to avoid overlaying busyLabel on windows
        leftToolBarSize.x = 0;
      }
      leftToolBar.setBounds(busyLabel.getLocation().x, y, leftToolBarSize.x, leftToolBarSize.y);
    }
    if (titleLabel != null && !titleLabel.isDisposed()) {
      // center align title text in title region
      Point size = titleLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
      int y = (titleLabel.getParent().getSize().y - size.y) / 2;
      titleLabel.setBounds(
          busyLabel.getLocation().x + LEFT_TOOLBAR_HEADER_TOOLBAR_PADDING + leftToolBarSize.x,
          y,
          size.x,
          size.y);
    }
  }
Example #4
0
  private void changeTemplateSize() {
    templateCode.pack();
    Font font;
    if (templateCode.getBounds().height > templateCodeGroup.getBounds().height)
      font = new Font(mainPageComposite.getDisplay(), "Courier New", 10, SWT.NORMAL);
    else font = new Font(mainPageComposite.getDisplay(), "Courier New", 14, SWT.NORMAL);

    templateCode.setFont(font);
    templateCode.setBounds(
        10, this.getLowerRightCoordinate(checkbox_HighlightSmellCode).y + 5, 500, 170);
    selectComposite.pack();
  }
Example #5
0
  /**
   * 建立Page外觀View
   *
   * @param composite
   */
  private void buildPage(Composite composite) {
    selectComposite = new Composite(composite, SWT.NONE);

    //		addLibBtn = new Button(composite, SWT.PUSH);
    //		addLibBtn.setText("Add Tag Library");
    //		addLibBtn.setLocation(getBoundsPoint(detAllBtn).x + 20, 10);
    //		addLibBtn.pack();
    //		addLibBtn.addSelectionListener(new SelectionAdapter() {
    //			@Override
    //			public void widgetSelected(SelectionEvent e) {
    //				ISelectionService selectionService =
    // Workbench.getInstance().getActiveWorkbenchWindow().getSelectionService();
    //				ISelection selection = selectionService.getSelection();
    //				IProject project = null;
    //				if(selection instanceof IStructuredSelection) {
    //				    Object element = ((IStructuredSelection)selection).getFirstElement();
    //				    if (element instanceof IResource) {
    //				        project= ((IResource)element).getProject();
    //				    } else if (element instanceof PackageFragmentRootContainer) {
    //				        IJavaProject jProject = ((PackageFragmentRootContainer)element).getJavaProject();
    //				        project = jProject.getProject();
    //				    } else if (element instanceof IJavaElement) {
    //				        IJavaProject jProject= ((IJavaElement)element).getJavaProject();
    //				        project = jProject.getProject();
    //				    }
    //				} else if (selection instanceof ITextSelection) {
    //				    System.out.println("Fail");
    //				    return;
    //				}
    //				File lib = new File(project.getLocation().toFile().getPath() + "/lib");
    //				if(!lib.exists())
    //					lib.mkdir();
    //				File jar = new File(project.getLocation().toFile().getPath() + "/lib/Tag.jar");
    //				JarFileMaker jarFileMaker = new JarFileMaker();
    //				File test = new File("bin");
    //				jarFileMaker.createJarFile(jar, test, "ntut.csie.robusta.agile.exception");
    //			}
    //		});

    // 上半部,選擇要偵測的Smell群組
    smellTypeGroup = new Group(selectComposite, SWT.NONE);
    smellTypeGroup.setText(resource.getString("settingPage.smell.type"));
    smellTypeGroup.setLocation(10, 5);

    // 是否要選擇性偵測的Button
    checkbox_DetectAllSmells = new Button(smellTypeGroup, SWT.CHECK);
    checkbox_DetectAllSmells.setText(resource.getString("check.all.smell"));
    checkbox_DetectAllSmells.setLocation(10, 20);
    checkbox_DetectAllSmells.pack();
    checkbox_DetectAllSmells.setSelection(isDetectingAllSmells);
    checkbox_DetectAllSmells.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent e) {
            isDetectingAllSmells = !isDetectingAllSmells;
            setUserSetting();
          }
        });

    // 選擇EH Smell List
    smellList =
        new Table(
            smellTypeGroup,
            SWT.CHECK | SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER | SWT.HIDE_SELECTION);
    smellList.setLocation(
        checkbox_DetectAllSmells.getBounds().x,
        checkbox_DetectAllSmells.getBounds().y + checkbox_DetectAllSmells.getBounds().height);
    smellList.setFont(new Font(composite.getDisplay(), "Arial", 11, SWT.NONE));
    smellList.setLinesVisible(true);
    smellList.setHeaderVisible(true);
    smellList.setItemCount(7);

    final TableColumn smellColumn = new TableColumn(smellList, SWT.NONE);
    String smellColumnDisplayText = resource.getString("settingPage.smell.type");
    smellColumn.setText(smellColumnDisplayText);
    smellColumn.setWidth(smellColumnDisplayText.length() * 9);
    // 自動調整bad smell Type Column的大小
    smellColumn.pack();
    final TableColumn descColumn = new TableColumn(smellList, SWT.NONE);
    descColumn.setText(resource.getString("settingPage.smell.description"));

    for (int i = 0; i < RLMarkerAttribute.CS_TOTAL_TYPE.length; i++) {
      TableItem item = smellList.getItem(i);
      item.setText(0, RLMarkerAttribute.CS_TOTAL_TYPE[i].replace('_', ' '));
      item.setFont(0, new Font(composite.getDisplay(), "Arial", 11, SWT.BOLD));
      item.setText(1, descText[i]);
    }
    // 自動調整bad smell Description Column的大小
    descColumn.pack();

    // 自動調整設定主頁面上半部視窗的大小
    smellList.pack();
    smellTypeGroup.pack();

    // Template Group
    templateCodeGroup = new Group(selectComposite, SWT.NONE);
    templateCodeGroup.setText(resource.getString("settingPage.codeExample"));
    templateCodeGroup.setLocation(10, getLowerRightCoordinate(smellTypeGroup).y + 5);

    // 是否要醒目標記程式碼
    checkbox_HighlightSmellCode = new Button(templateCodeGroup, SWT.CHECK);
    checkbox_HighlightSmellCode.setText(resource.getString("settingPage.codeExample.highlight"));
    checkbox_HighlightSmellCode.setLocation(10, 20);
    checkbox_HighlightSmellCode.pack();
    checkbox_HighlightSmellCode.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent e) {
            isShowWarning = checkbox_HighlightSmellCode.getSelection();

            int index = smellList.getSelectionIndex();
            if (index != -1) {
              changeTemplateText(index);
            }
          }
        });

    // Template Text
    templateCode = new StyledText(templateCodeGroup, SWT.BORDER | SWT.V_SCROLL);
    templateCode.setBounds(
        10, this.getLowerRightCoordinate(checkbox_HighlightSmellCode).y, 500, 170);
    templateCode.setText("");
    Font font = new Font(composite.getDisplay(), "Courier New", 14, SWT.NORMAL);
    templateCode.setFont(font);
    templateCodeGroup.pack();

    // 自動調整設定主頁面Container的大小
    selectComposite.pack();
    selectComposite.setSize(
        getLowerRightCoordinate(smellTypeGroup).x + 15, selectComposite.getBounds().height);
  }
  /** Open the window. */
  public void open() {
    display = Display.getDefault();
    shlSenderWindow = new Shell();
    shlSenderWindow.setSize(373, 600);
    shlSenderWindow.setText("Receiver Window");

    Label senderNameLabel = new Label(shlSenderWindow, SWT.NONE);
    senderNameLabel.setBounds(23, 146, 111, 17);
    senderNameLabel.setText("Sender Name");

    senderNameText = new Text(shlSenderWindow, SWT.BORDER);
    senderNameText.setBounds(155, 136, 183, 27);

    Label recepientNameLabel = new Label(shlSenderWindow, SWT.NONE);
    recepientNameLabel.setBounds(23, 182, 111, 17);
    recepientNameLabel.setText("Recepient Name");

    recepientNameText = new Text(shlSenderWindow, SWT.BORDER);
    recepientNameText.setBounds(155, 172, 183, 27);

    Label TicketIdLabel = new Label(shlSenderWindow, SWT.NONE);
    TicketIdLabel.setBounds(23, 215, 111, 17);
    TicketIdLabel.setText("Ticket ID");

    messageIDText = new Text(shlSenderWindow, SWT.BORDER);
    messageIDText.setBounds(155, 205, 183, 27);

    Label ticketLabel = new Label(shlSenderWindow, SWT.NONE);
    ticketLabel.setBounds(23, 251, 70, 17);
    ticketLabel.setText("Ticket");

    ticketText = new StyledText(shlSenderWindow, SWT.BORDER);
    ticketText.setBounds(10, 287, 347, 183);

    closeButton = new Button(shlSenderWindow, SWT.NONE);
    closeButton.setBounds(233, 532, 105, 29);
    closeButton.setText("Close");
    closeButton.addSelectionListener(this);

    queueList = new List(shlSenderWindow, SWT.V_SCROLL | SWT.H_SCROLL);
    queueList.setBounds(23, 33, 111, 92);

    Label queueToConnectLabel = new Label(shlSenderWindow, SWT.NONE);
    queueToConnectLabel.setBounds(10, 10, 124, 17);
    queueToConnectLabel.setText("Queue to connect");

    retrieveMessageButton = new Button(shlSenderWindow, SWT.NONE);
    retrieveMessageButton.setBounds(191, 65, 122, 29);
    retrieveMessageButton.setText("Retrieve Message");
    retrieveMessageButton.addSelectionListener(this);

    UpdateExchangeList(MessageReceiverHighLevelClass.GetQueueList());

    shlSenderWindow.open();
    shlSenderWindow.layout();
    while (!shlSenderWindow.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
  }
  /** This method initializes sShell */
  private void createSShell() {
    sShell = new Shell();
    sShell.setText("Hosts Juggler");
    sShell.setLayout(null);
    sShell.setSize(new Point(726, 766));

    /*
     * Menu
     */
    final Menu m = new Menu(sShell, SWT.BAR);
    sShell.setMenuBar(m);

    /* Hosts File */
    // create a file menu and add an exit item
    final MenuItem file = new MenuItem(m, SWT.CASCADE);
    file.setText("&Hosts File");
    final Menu filemenu = new Menu(sShell, SWT.DROP_DOWN);
    file.setMenu(filemenu);
    final MenuItem openItem = new MenuItem(filemenu, SWT.CASCADE);
    openItem.setText("&Open");
    final Menu submenu = new Menu(sShell, SWT.DROP_DOWN);
    openItem.setMenu(submenu);
    final MenuItem childItem = new MenuItem(submenu, SWT.PUSH);
    childItem.setText("&Child\tCTRL+C");
    childItem.setAccelerator(SWT.CTRL + 'C');
    final MenuItem dialogItem = new MenuItem(submenu, SWT.PUSH);
    dialogItem.setText("&Dialog\tCTRL+D");
    dialogItem.setAccelerator(SWT.CTRL + 'D');
    final MenuItem separator = new MenuItem(filemenu, SWT.SEPARATOR);
    final MenuItem exitItem = new MenuItem(filemenu, SWT.PUSH);
    exitItem.setText("E&xit");

    // create an edit menu and add cut copy and paste items
    final MenuItem edit = new MenuItem(m, SWT.CASCADE);
    edit.setText("&Edit");
    final Menu editmenu = new Menu(sShell, SWT.DROP_DOWN);
    edit.setMenu(editmenu);
    final MenuItem cutItem = new MenuItem(editmenu, SWT.PUSH);
    cutItem.setText("&Cut");
    final MenuItem copyItem = new MenuItem(editmenu, SWT.PUSH);
    copyItem.setText("Co&py");
    final MenuItem pasteItem = new MenuItem(editmenu, SWT.PUSH);
    pasteItem.setText("&Paste");

    // create an options menu and add menu items
    final MenuItem options = new MenuItem(m, SWT.CASCADE);
    options.setText("&Options");
    final Menu optionsmenu = new Menu(sShell, SWT.DROP_DOWN);
    options.setMenu(optionsmenu);
    final MenuItem checkItem = new MenuItem(optionsmenu, SWT.CHECK);
    checkItem.setText("&Checked Option");
    final MenuItem optionsseparator = new MenuItem(optionsmenu, SWT.SEPARATOR);
    final MenuItem radioItem1 = new MenuItem(optionsmenu, SWT.RADIO);
    radioItem1.setText("Radio &One");
    final MenuItem radioItem2 = new MenuItem(optionsmenu, SWT.RADIO);
    radioItem2.setText("Radio &Two");

    // create a Window menu and add Child item
    final MenuItem window = new MenuItem(m, SWT.CASCADE);
    window.setText("&Window");
    final Menu windowmenu = new Menu(sShell, SWT.DROP_DOWN);
    window.setMenu(windowmenu);
    final MenuItem maxItem = new MenuItem(windowmenu, SWT.PUSH);
    maxItem.setText("Ma&ximize");
    final MenuItem minItem = new MenuItem(windowmenu, SWT.PUSH);
    minItem.setText("Mi&nimize");

    // create a Help menu and add an about item
    final MenuItem help = new MenuItem(m, SWT.CASCADE);
    help.setText("&Help");
    final Menu helpmenu = new Menu(sShell, SWT.DROP_DOWN);
    help.setMenu(helpmenu);
    final MenuItem aboutItem = new MenuItem(helpmenu, SWT.PUSH);
    aboutItem.setText("&About");

    //		/* File */
    //		MenuItem fileItem = new MenuItem (menuBar, SWT.CASCADE);
    //		fileItem.setText("&Hosts File");
    //
    //		Menu submenu = new Menu(sShell, SWT.DROP_DOWN);
    //		fileItem.setMenu(submenu);
    //		MenuItem menuItem = new MenuItem (submenu, SWT.PUSH);
    //		menuItem.addListener(SWT.Selection, new Listener()
    //		{
    //			public void handleEvent(Event e)
    //			{
    //				System.out.println ("Create");
    //			}
    //		});
    //		menuItem.setText("Create &New\tCtrl+N");
    //		menuItem.setAccelerator(SWT.MOD1 + 'N');

    /*
     * Active hosts file location
     */
    label = new Label(sShell, SWT.NONE);
    label.setBounds(new Rectangle(15, 10, 692, 15));

    switchHostsFileButton = new Button(sShell, SWT.NONE);
    switchHostsFileButton.setBounds(new Rectangle(330, 682, 103, 26));
    switchHostsFileButton.setText("Switch");

    switchHostsFileButton.addSelectionListener(
        new org.eclipse.swt.events.SelectionAdapter() {
          @Override
          public void widgetDefaultSelected(SelectionEvent e) {}

          @Override
          public void widgetSelected(SelectionEvent e) {
            openSwitchDialog(sShell);
          }
        });

    minimizeToTrayButton = new Button(sShell, SWT.NONE);
    minimizeToTrayButton.setBounds(new Rectangle(451, 682, 108, 28));
    minimizeToTrayButton.setText("Hide");
    exitButton = new Button(sShell, SWT.NONE);
    exitButton.setBounds(new Rectangle(574, 683, 117, 28));
    exitButton.setText("Exit");

    /*
     * Active file
     */
    activeHostsFileStyledText =
        new StyledText(sShell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY);
    activeHostsFileStyledText.setText("");
    activeHostsFileStyledText.setTabs(5);
    activeHostsFileStyledText.setBounds(new Rectangle(15, 33, 694, 616));
  }