예제 #1
0
파일: View.java 프로젝트: shader/gdr
  /**
   * Initialize the toolbar with icons and selection listeners in the appropriate part of the window
   */
  public void initToolbar() {

    Device dev = shell.getDisplay();
    try {
      exitImg = new Image(dev, "img/exit.png");
      //            openImg = new Image(dev, "img/open.png");
      playImg = new Image(dev, "img/play.png");
      //            pauseImg = new Image(dev, "img/pause.png");

    } catch (Exception e) {
      System.out.println("Cannot load images");
      System.out.println(e.getMessage());
      System.exit(1);
    }

    ToolBar toolBar = new ToolBar(shell, SWT.BORDER);

    GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    toolBar.setLayoutData(gridData);

    ToolItem exit = new ToolItem(toolBar, SWT.PUSH);
    exit.setImage(exitImg);

    // ToolItem open = new ToolItem(toolBar, SWT.PUSH);
    // exit.setImage(openImg);

    ToolItem play = new ToolItem(toolBar, SWT.PUSH);
    play.setImage(playImg);

    //        ToolItem pause = new ToolItem(toolBar, SWT.PUSH);
    //        pause.setImage(pauseImg);

    toolBar.pack();

    exit.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            System.exit(0);
          }
        });

    // open.addSelectionListener(new SelectionAdapter() {
    //     @Override
    //     public void widgetSelected(SelectionEvent e) {
    //         FileDialog dialog = new FileDialog(shell, SWT.NULL);
    //         String path = dialog.open();
    //     }
    // });

    play.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            controller.RunAnimation();
          }
        });
  }
예제 #2
0
 void updateViewport() {
   baseEditor.lineCountEvent(text.getLineCount());
   int start = 0;
   try {
     start = text.getTopIndex() - 1;
   } catch (Exception e) {
     e.printStackTrace(System.out);
   }
   if (start < 0) start = 0;
   int end = start + text.getClientArea().height / text.getLineHeight();
   baseEditor.visibleTextEvent(start, end - start + 2);
 }
  public void updateParentFileCombo(FileObject selectedItem) {
    try {
      List<FileObject> parentChain = new ArrayList<FileObject>();
      // are we a directory?
      try {
        if (selectedItem.getType() == FileType.FOLDER && selectedItem.getType().hasChildren()) {
          // we have real children....
          parentChain.add(selectedItem);
        }
      } catch (Exception e) {
        // we are not a folder
      }
      FileObject parentFileObject;
      parentFileObject = selectedItem.getParent();
      while (parentFileObject != null) {
        parentChain.add(parentFileObject);
        parentFileObject = parentFileObject.getParent();
      }

      File roots[] = File.listRoots();
      if (currentPanel != null) {
        for (int i = 0; i < roots.length; i++) {
          parentChain.add(currentPanel.resolveFile(roots[i].getAbsolutePath()));
        }
      }

      String items[] = new String[parentChain.size()];
      int idx = 0;
      for (int i = parentChain.size() - 1; i >= 0; i--) {
        items[idx++] = ((FileObject) parentChain.get(i)).getName().getURI();
      }

      openFileCombo.setItems(items);
      openFileCombo.select(items.length - 1);
    } catch (Exception e) {
      e.printStackTrace();
      // then let's not update the GUI
    }
  }
예제 #4
0
  /** Initializes the GUI. */
  private void initGUI() {
    try {
      getShell()
          .addDisposeListener(
              new DisposeListener() {
                public void widgetDisposed(DisposeEvent evt) {
                  shellWidgetDisposed(evt);
                }
              });

      getShell()
          .addControlListener(
              new ControlAdapter() {
                public void controlResized(ControlEvent evt) {
                  shellControlResized(evt);
                }
              });

      getShell()
          .addControlListener(
              new ControlAdapter() {
                public void controlMoved(ControlEvent evt) {
                  shellControlMoved(evt);
                }
              });

      GridLayout thisLayout = new GridLayout();
      this.setLayout(thisLayout);
      {
        GridData toolBarLData = new GridData();
        toolBarLData.grabExcessHorizontalSpace = true;
        toolBarLData.horizontalAlignment = GridData.FILL;
        toolBar = new ToolBar(this, SWT.FLAT);
        toolBar.setLayoutData(toolBarLData);
        toolBar.setBackgroundImage(SWTResourceManager.getImage("images/ToolbarBackground.gif"));
        {
          newToolItem = new ToolItem(toolBar, SWT.NONE);
          newToolItem.setImage(SWTResourceManager.getImage("images/new.gif"));
          newToolItem.setToolTipText("New");
        }
        {
          openToolItem = new ToolItem(toolBar, SWT.NONE);
          openToolItem.setToolTipText("Open");
          openToolItem.setImage(SWTResourceManager.getImage("images/open.gif"));
          openToolItem.addSelectionListener(
              new SelectionAdapter() {
                public void widgetSelected(SelectionEvent evt) {
                  openToolItemWidgetSelected(evt);
                }
              });
        }
        {
          saveToolItem = new ToolItem(toolBar, SWT.NONE);
          saveToolItem.setToolTipText("Save");
          saveToolItem.setImage(SWTResourceManager.getImage("images/save.gif"));
        }
      }
      {
        clientArea = new Composite(this, SWT.NONE);
        GridData clientAreaLData = new GridData();
        clientAreaLData.grabExcessHorizontalSpace = true;
        clientAreaLData.grabExcessVerticalSpace = true;
        clientAreaLData.horizontalAlignment = GridData.FILL;
        clientAreaLData.verticalAlignment = GridData.FILL;
        clientArea.setLayoutData(clientAreaLData);
        clientArea.setLayout(null);
      }
      {
        statusArea = new Composite(this, SWT.NONE);
        GridLayout statusAreaLayout = new GridLayout();
        statusAreaLayout.makeColumnsEqualWidth = true;
        statusAreaLayout.horizontalSpacing = 0;
        statusAreaLayout.marginHeight = 0;
        statusAreaLayout.marginWidth = 0;
        statusAreaLayout.verticalSpacing = 0;
        statusAreaLayout.marginLeft = 3;
        statusAreaLayout.marginRight = 3;
        statusAreaLayout.marginTop = 3;
        statusAreaLayout.marginBottom = 3;
        statusArea.setLayout(statusAreaLayout);
        GridData statusAreaLData = new GridData();
        statusAreaLData.horizontalAlignment = GridData.FILL;
        statusAreaLData.grabExcessHorizontalSpace = true;
        statusArea.setLayoutData(statusAreaLData);
        statusArea.setBackground(SWTResourceManager.getColor(239, 237, 224));
        {
          statusText = new Label(statusArea, SWT.BORDER);
          statusText.setText(" Ready");
          GridData txtStatusLData = new GridData();
          txtStatusLData.horizontalAlignment = GridData.FILL;
          txtStatusLData.grabExcessHorizontalSpace = true;
          txtStatusLData.verticalIndent = 3;
          statusText.setLayoutData(txtStatusLData);
        }
      }
      thisLayout.verticalSpacing = 0;
      thisLayout.marginWidth = 0;
      thisLayout.marginHeight = 0;
      thisLayout.horizontalSpacing = 0;
      thisLayout.marginTop = 3;
      this.setSize(474, 312);
      {
        menu1 = new Menu(getShell(), SWT.BAR);
        getShell().setMenuBar(menu1);
        {
          fileMenuItem = new MenuItem(menu1, SWT.CASCADE);
          fileMenuItem.setText("&File");
          {
            fileMenu = new Menu(fileMenuItem);
            {
              newFileMenuItem = new MenuItem(fileMenu, SWT.PUSH);
              newFileMenuItem.setText("&New");
              newFileMenuItem.setImage(SWTResourceManager.getImage("images/new.gif"));
            }
            {
              openFileMenuItem = new MenuItem(fileMenu, SWT.PUSH);
              openFileMenuItem.setText("&Open");
              openFileMenuItem.setImage(SWTResourceManager.getImage("images/open.gif"));
              openFileMenuItem.addSelectionListener(
                  new SelectionAdapter() {
                    public void widgetSelected(SelectionEvent evt) {
                      openFileMenuItemWidgetSelected(evt);
                    }
                  });
            }
            {
              closeFileMenuItem = new MenuItem(fileMenu, SWT.CASCADE);
              closeFileMenuItem.setText("Close");
            }
            {
              fileMenuSep1 = new MenuItem(fileMenu, SWT.SEPARATOR);
            }
            {
              saveFileMenuItem = new MenuItem(fileMenu, SWT.PUSH);
              saveFileMenuItem.setText("&Save");
              saveFileMenuItem.setImage(SWTResourceManager.getImage("images/save.gif"));
              saveFileMenuItem.addSelectionListener(
                  new SelectionAdapter() {
                    public void widgetSelected(SelectionEvent evt) {
                      saveFileMenuItemWidgetSelected(evt);
                    }
                  });
            }
            {
              fileMenuSep2 = new MenuItem(fileMenu, SWT.SEPARATOR);
            }
            {
              exitMenuItem = new MenuItem(fileMenu, SWT.CASCADE);
              exitMenuItem.setText("E&xit");
              exitMenuItem.addSelectionListener(
                  new SelectionAdapter() {
                    public void widgetSelected(SelectionEvent evt) {
                      exitMenuItemWidgetSelected(evt);
                    }
                  });
            }
            fileMenuItem.setMenu(fileMenu);
          }
        }
        {
          helpMenuItem = new MenuItem(menu1, SWT.CASCADE);
          helpMenuItem.setText("&Help");
          {
            helpMenu = new Menu(helpMenuItem);
            {
              aboutMenuItem = new MenuItem(helpMenu, SWT.CASCADE);
              aboutMenuItem.setText("&About");
              aboutMenuItem.addSelectionListener(
                  new SelectionAdapter() {
                    public void widgetSelected(SelectionEvent evt) {
                      aboutMenuItemWidgetSelected(evt);
                    }
                  });
            }
            helpMenuItem.setMenu(helpMenu);
          }
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }