Ejemplo n.º 1
0
 /* (non-Javadoc)
  * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
  */
 @Override
 protected void configureShell(Shell newShell) {
   super.configureShell(newShell);
   newShell.setText("Tags");
   newShell.setImage(
       TagSEAPlugin.getDefault().getImageRegistry().get(ITagSEAImageConstants.IMG_TAG));
 }
Ejemplo n.º 2
0
 public static void main(java.lang.String[] args) {
   org.eclipse.swt.widgets.Display display = new org.eclipse.swt.widgets.Display();
   org.eclipse.swt.widgets.Shell shell = new org.eclipse.swt.widgets.Shell(display);
   shell.setLayout(new org.eclipse.swt.layout.FillLayout());
   shell.setText(getResourceString("window.title"));
   java.io.InputStream stream =
       (org.eclipse.swt.examples.browserexample.BrowserExample.class)
           .getResourceAsStream(iconLocation);
   org.eclipse.swt.graphics.Image icon = new org.eclipse.swt.graphics.Image(display, stream);
   shell.setImage(icon);
   try {
     stream.close();
   } catch (java.io.IOException e) {
     e.printStackTrace();
   }
   org.eclipse.swt.examples.browserexample.BrowserExample app =
       new org.eclipse.swt.examples.browserexample.BrowserExample(shell, true);
   app.setShellDecoration(icon, true);
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) {
       display.sleep();
     }
   }
   icon.dispose();
   app.dispose();
   display.dispose();
 }
Ejemplo n.º 3
0
  public static void main(String[] args) throws IOException {
    List<Emoticon> emoticons = new ArrayList<Emoticon>();
    new EmoFormat(emoticons, protocols).load();

    Display display = new Display();

    shell = new Shell(display);
    DirectoryDialog dialog = new DirectoryDialog(shell, SWT.NONE);
    dialog.setText("Select folder with emoticon images");
    String path = dialog.open();
    if (path == null) return;
    //		String path = "C:\\Desenvolvimento\\Miranda\\bin\\Debug
    // Unicode\\Customize\\Emoticons\\Originals";
    File mepPath = new File(path);
    if (!mepPath.exists()) return;

    mepFormat = new MepFormat(mepPath, emoticons, protocols);
    mep = mepFormat.load();

    createMainWindow(shell);

    shell.setText("Emoticon Pack Editor");
    shell.setImage(Images.get("data/Defaults/smile.png"));
    shell.setSize(500, 600);
    shell.open();

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
Ejemplo n.º 4
0
 @Override
 public void configureShell(Shell newShell) {
   super.configureShell(newShell);
   newShell.setText(
       String.format("%s v%s", SystemDefine.NAME, SystemDefine.MAJOR_VERSION)); // $NON-NLS-1$
   newShell.setImage(GlobalImageUtils.getTadpoleIcon());
 }
Ejemplo n.º 5
0
 @Override
 protected void configureShell(final Shell shell) {
   super.configureShell(shell);
   shell.setText("XPath Variables Dialog");
   final Image headImage = ImageManager.getInstance().getSharedImage(StandardImages.TREE_SMALL);
   shell.setImage(headImage);
 }
  private void createDialog(Shell applicationShell) {
    if (dialog == null || dialog.isDisposed()) {
      dialog = new Shell(applicationShell, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.APPLICATION_MODAL);

      if (applicationShell.getImage() != null) {
        dialog.setImage(applicationShell.getImage());
      }

      dialog.addListener(
          SWT.Close,
          new Listener() {
            public void handleEvent(Event event) {
              hideCustomPanelChildren();
            }
          });

      dialog.addDisposeListener(
          new DisposeListener() {
            public void widgetDisposed(DisposeEvent arg0) {
              disposeImages();
            }
          });

      if (fileDialogMode != VFS_DIALOG_SAVEAS) {
        dialog.setText(Messages.getString("VfsFileChooserDialog.openFile")); // $NON-NLS-1$
      } else {
        dialog.setText(Messages.getString("VfsFileChooserDialog.saveAs")); // $NON-NLS-1$
      }
      dialog.setLayout(new GridLayout());
      dialog.setBackgroundMode(SWT.INHERIT_FORCE);
      dialog.setBackground(dialog.getDisplay().getSystemColor(SWT.COLOR_WHITE));
      createCustomUIPanel(dialog);
    }
  }
Ejemplo n.º 7
0
 protected void mainLayout(Class<?> PKG, String prefix, Image img) {
   display = parent.getDisplay();
   shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.MIN | SWT.APPLICATION_MODAL);
   props.setLook(shell);
   shell.setImage(img);
   shell.setLayout(new FormLayout());
   shell.setText(BaseMessages.getString(PKG, prefix + ".Shell.Title"));
 }
Ejemplo n.º 8
0
 @Override
 protected void configureShell(Shell shell) {
   super.configureShell(shell);
   if (title != null) {
     shell.setText(title);
   }
   if (titleImage != null) {
     shell.setImage(titleImage);
   }
 }
Ejemplo n.º 9
0
  @Override
  protected void configureShell(Shell shell) {
    super.configureShell(shell);
    shell.setText("Traceview: " + mTraceName);

    InputStream in = getClass().getClassLoader().getResourceAsStream("icons/traceview-128.png");
    if (in != null) {
      shell.setImage(new Image(shell.getDisplay(), in));
    }

    shell.setBounds(100, 10, 1282, 900);
  }
  /** Creates the icon of the window shell. */
  private void setWindowImage(Shell androidSdkUpdater) {
    String imageName = "android_icon_16.png"; // $NON-NLS-1$
    if (SdkConstants.currentPlatform() == SdkConstants.PLATFORM_DARWIN) {
      imageName = "android_icon_128.png"; // $NON-NLS-1$
    }

    if (mUpdaterData != null) {
      ImageFactory imgFactory = mUpdaterData.getImageFactory();
      if (imgFactory != null) {
        mAndroidSdkUpdater.setImage(imgFactory.getImageByName(imageName));
      }
    }
  }
Ejemplo n.º 11
0
 public static void main(String[] args) {
   Display display = Display.getDefault();
   Shell shell = new Shell(display);
   @SuppressWarnings("unused")
   MainWindow inst = new MainWindow(shell, SWT.NULL);
   shell.setLayout(new FillLayout());
   shell.setImage(SWTResourceManager.getImage("images/16x16.png"));
   shell.setText("Change This Title");
   shell.setBackgroundImage(SWTResourceManager.getImage("images/ToolbarBackground.gif"));
   shell.layout();
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
 }
Ejemplo n.º 12
0
 public int open() {
   Shell parent = this.getParent();
   shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
   shell.setText(getText());
   shell.setImage(parent.getImage());
   shell.setLayout(new GridLayout());
   createContentComposite(shell);
   createButtonBarComposite(shell);
   shell.pack();
   centerShell(parent, shell);
   shell.open();
   Display display = parent.getDisplay();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
   return result;
 }
 /**
  * Opens the dialog and returns the input
  *
  * @return String
  */
 public String open() {
   // Create the dialog window
   Shell shell = new Shell(getParent(), getStyle());
   shell.setText(getText());
   shell.setImage(UIUtils.getImageRegistry().get("sfdc_icon")); // $NON-NLS-1$
   createContents(shell);
   shell.pack();
   shell.open();
   Display display = getParent().getDisplay();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) {
       display.sleep();
     }
   }
   // Return the entered value, or null
   return input;
 }
Ejemplo n.º 14
0
  /** This method initializes shell */
  private void initShell(final Shell shell) {
    FormLayout formLayout = new FormLayout();
    shell.setLayout(formLayout);

    // load and set icon
    Image image = new Image(shell.getDisplay(), Labels.getInstance().getImageAsStream("icon"));
    shell.setImage(image);

    shell.addListener(
        SWT.Close,
        new Listener() {
          public void handleEvent(Event event) {
            // save dimensions!
            guiConfig.setMainWindowSize(shell.getSize(), shell.getMaximized());
          }
        });
  }
  /** This method initializes mainWindow */
  public void createMainWindow() {
    resultWindow = new Shell();
    resultWindow.setImage(new Image(Display.getCurrent(), "resources/MathWorldIcon.gif"));
    resultWindow.setText(title);
    resultWindow.setMaximized(false);
    resultWindow.setSize(new Point(394, 671));
    resultWindow.setLayout(new FillLayout());

    FormData formData2 = new FormData();
    formData2.bottom = new FormAttachment(100, -5);
    formData2.left = new FormAttachment(30, 50);
    formData2.right = new FormAttachment(70, -50);
    FormData formData1 = new FormData();
    formData1.bottom = new FormAttachment(100, -5);
    formData1.right = new FormAttachment(30, -50);
    formData1.left = new FormAttachment(0, 50);
    Text clusteringResultTextArea = new Text(resultWindow, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
    clusteringResultTextArea.setText(printedClusteringResult);
  }
Ejemplo n.º 16
0
  public void open() {

    Point size = new Point(400, 200);
    shell.setSize(size);

    Point l = getParent().getLocation();
    Point s = getParent().getSize();

    shell.setLocation(l.x + (s.x - size.x) / 2, l.y + (s.y - size.y) / 2);

    shell.setText(getText());
    shell.setImage(PenroseStudio.getImage(PenroseImage.LOGO));

    reset();

    shell.open();

    Display display = getParent().getDisplay();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
  }
  /** Create contents of the window. */
  protected void createContents() {

    shell = new Shell();
    shell.setImage(SWTResourceManager.getImage(PrintedLumpWindow.class, "/icon/App.ico"));
    shell.setSize(457, 244);
    shell.setText(loader.getValue(LabelConstants.LAYOUT_PRINTED_LUMPS_NEW_PRINTED_LUMPS));
    Label lblNameOfTheLump = new Label(shell, SWT.NONE);
    lblNameOfTheLump.setBounds(24, 38, 249, 15);
    lblNameOfTheLump.setText(loader.getValue(LabelConstants.LAYOUT_PRINTED_LUMPS_NAME_OF_THE_LUMP));

    txtNameOfTheLump = new Text(shell, SWT.BORDER);
    txtNameOfTheLump.setBounds(20, 77, 397, 25);

    Button btnPrintedLumpCancel = new Button(shell, SWT.NONE);
    btnPrintedLumpCancel.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent arg0) {
            shell.setVisible(false);
            shell.dispose();
          }
        });
    btnPrintedLumpCancel.setBounds(20, 149, 105, 32);
    btnPrintedLumpCancel.setText(loader.getValue(LabelConstants.LAYOUT_CANCEL));

    btnPrintedLumpSave = new Button(shell, SWT.NONE);
    btnPrintedLumpSave.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent arg0) {
            lumpsInterface.addPrintedLump(txtNameOfTheLump.getText());
            shell.setVisible(false);
            shell.dispose();
          }
        });
    btnPrintedLumpSave.setBounds(312, 149, 105, 32);
    btnPrintedLumpSave.setText(loader.getValue(LabelConstants.LAYOUT_SAVE));
  }
Ejemplo n.º 18
0
  @Override
  protected void configureShell(Shell newShell) {
    newShell.setText(getTitle());
    newShell.setImage(getImage());
    newShell.addPaintListener(
        new PaintListener() {
          public void paintControl(PaintEvent e) {
            Shell shell = (Shell) e.getSource();
            Rectangle rect = shell.getClientArea();
            rect.width--;
            rect.height--;
            Color c = new Color(shell.getDisplay(), 0x1E, 0x3E, 0x93);
            e.gc.setForeground(c);
            e.gc.drawRectangle(0, 0, rect.width, rect.height);
            c.dispose();

            c = new Color(shell.getDisplay(), 0xAA, 0xE1, 0xFF);
            e.gc.setForeground(c);
            e.gc.drawRectangle(1, 1, rect.width - 2, rect.height - 2);
            c.dispose();

            c = new Color(shell.getDisplay(), 0x53, 0xAE, 0xF3);
            e.gc.setForeground(c);
            e.gc.drawRectangle(2, 2, rect.width - 4, rect.height - 4);
            c.dispose();

            Color top = new Color(shell.getDisplay(), 0x15, 0x77, 0xD3);
            Color bottom = new Color(shell.getDisplay(), 0x68, 0xB6, 0xF7);
            String title = getTitle();
            Point extent = e.gc.textExtent(title);
            int height = Math.max(18, extent.y + 6);
            e.gc.setForeground(top);
            e.gc.setBackground(bottom);
            e.gc.fillGradientRectangle(2, 2, rect.width - 4, height, true);
            top.dispose();
            bottom.dispose();

            c = new Color(shell.getDisplay(), 0x4F, 0x93, 0xD5);
            e.gc.setForeground(c);
            e.gc.setBackground(shell.getBackground());
            e.gc.drawRectangle(3, 2 + height, rect.width - 6, 2 + height);
            c.dispose();

            Image image = getImage();
            Rectangle imageRect = image.getBounds();
            e.gc.drawImage(getImage(), 4, 2 + ((height - imageRect.height) >> 1));

            e.gc.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
            e.gc.setFont(Resources.getInstance().getDefaultFont());
            e.gc.drawString(
                title, 6 + imageRect.width, Math.max(5, (height - extent.y) >> 1), true);

            bottom = new Color(shell.getDisplay(), 0xCC, 0xEB, 0xFF);
            e.gc.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
            e.gc.setBackground(bottom);
            e.gc.fillGradientRectangle(
                3, 3 + height, rect.width - 5, rect.height - 5 - height, true);
            bottom.dispose();

            Rectangle btnRect = btnDefault.getBounds();
            c = new Color(shell.getDisplay(), 0x9A, 0xBD, 0xE2);
            int x = btnRect.x;
            int y = btnRect.y - 5;
            while (x < rect.width - 3) {
              e.gc.setForeground(c);
              e.gc.drawPoint(x, y);
              e.gc.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
              e.gc.drawPoint(x, y + 1);
              x += 3;
            }
            c.dispose();

            e.gc.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLUE));
            TextLayout layout = new TextLayout(shell.getDisplay());
            layout.setWidth(215);
            layout.setText(getTip());
            layout.setFont(res.getDefaultFont());
            layout.draw(e.gc, 3 + getLeftMargin(), 2 + height + getTopMargin());
            layout.dispose();
          }
        });
    newShell.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseDown(MouseEvent e) {
            downX = e.x;
            downY = e.y;
            isMove = true;
          }

          @Override
          public void mouseUp(MouseEvent e) {
            isMove = false;
          }
        });
    newShell.addMouseMoveListener(
        new MouseMoveListener() {
          public void mouseMove(MouseEvent e) {
            if (isMove) {
              Point loc = getShell().getLocation();
              int x = loc.x + e.x - downX;
              int y = loc.y + e.y - downY;
              getShell().setLocation(x, y);
            }
          }
        });

    // create default button
    newShell.setLayout(new FormLayout());
    // close button
    Label lblClose = new Label(newShell, SWT.CENTER);
    lblClose.setImage(res.getImage(Resources.bmpCloseNormal));
    FormData fd = new FormData();
    fd.top = new FormAttachment(0, 3);
    fd.height = 16;
    fd.right = new FormAttachment(100, -3);
    fd.width = 17;
    lblClose.setLayoutData(fd);
    lblClose.addMouseTrackListener(
        new MouseTrackAdapter() {
          @Override
          public void mouseEnter(MouseEvent e) {
            Label lbl = (Label) e.getSource();
            lbl.setImage(res.getImage(Resources.bmpCloseHover));
          }

          @Override
          public void mouseExit(MouseEvent e) {
            Label lbl = (Label) e.getSource();
            lbl.setImage(res.getImage(Resources.bmpCloseNormal));
          }
        });
    lblClose.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseDown(MouseEvent e) {
            Label lbl = (Label) e.getSource();
            lbl.setImage(res.getImage(Resources.bmpCloseDown));
          }

          @Override
          public void mouseUp(MouseEvent e) {
            getShell().close();
          }
        });
    btnDefault = new Slat(newShell);
    btnDefault.setText(getButtonLabel());
    fd = new FormData();
    fd.bottom = new FormAttachment(100, -6);
    fd.left = new FormAttachment(0, 6);
    btnDefault.setLayoutData(fd);
    btnDefault.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseUp(MouseEvent e) {
            getShell().close();
            onButton();
          }
        });
    btnDefault.setVisible(showButton());
  }
Ejemplo n.º 19
0
  protected void open(Shell shell) {
    this.accepted = false;

    final Shell dialog = DialogUtils.newDialog(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);

    dialog.setLayout(new GridLayout());
    dialog.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    dialog.setImage(TuxGuitar.instance().getIconManager().getAppIcon());
    dialog.setText(TuxGuitar.getProperty("tuxguitar-community.share-dialog.title"));

    Group group = new Group(dialog, SWT.SHADOW_ETCHED_IN);
    group.setLayout(makeGroupLayout(5));
    group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    group.setText(TuxGuitar.getProperty("tuxguitar-community.share-dialog.details"));

    // -------USERNAME---------------------------------
    Label usernameLabel = new Label(group, SWT.NULL);
    usernameLabel.setLayoutData(makeLabelData());
    usernameLabel.setText(
        TuxGuitar.getProperty("tuxguitar-community.share-dialog.details.user") + ":");

    final Text usernameText = new Text(group, SWT.BORDER | SWT.READ_ONLY);
    usernameText.setLayoutData(makeUsernameTextData());
    usernameText.setText(TGCommunitySingleton.getInstance().getAuth().getUsername());

    final Button usernameChooser = new Button(group, SWT.PUSH);
    usernameChooser.setText("...");
    usernameChooser.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            TGCommunityAuthDialog authDialog = new TGCommunityAuthDialog();
            authDialog.open(dialog);
            if (authDialog.isAccepted()) {
              TGCommunitySingleton.getInstance().getAuth().update();
              usernameText.setText(TGCommunitySingleton.getInstance().getAuth().getUsername());
            }
          }
        });

    // -------TITLE------------------------------------
    Label titleLabel = new Label(group, SWT.NULL);
    titleLabel.setLayoutData(makeLabelData());
    titleLabel.setText(
        TuxGuitar.getProperty("tuxguitar-community.share-dialog.details.title") + ":");

    final Text titleText = new Text(group, SWT.BORDER);
    titleText.setLayoutData(makeTextData());
    titleText.setText(this.file.getTitle());

    // -------TAGKEYS------------------------------------
    Label tagkeysLabel = new Label(group, SWT.NULL);
    tagkeysLabel.setLayoutData(makeLabelData());
    tagkeysLabel.setText(
        TuxGuitar.getProperty("tuxguitar-community.share-dialog.details.tagkeys") + ":");

    final Text tagkeysText = new Text(group, SWT.BORDER);
    tagkeysText.setLayoutData(makeTextData());
    tagkeysText.setText(this.file.getTagkeys());

    // -------DESCRIPTION------------------------------------
    Label descriptionLabel = new Label(group, SWT.NULL);
    descriptionLabel.setLayoutData(makeLabelData());
    descriptionLabel.setText(
        TuxGuitar.getProperty("tuxguitar-community.share-dialog.details.description") + ":");

    final Text descriptionText = new Text(group, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
    descriptionText.setLayoutData(makeTextAreaData());
    descriptionText.setText(this.file.getDescription());

    // ------------------BUTTONS--------------------------
    Composite buttons = new Composite(dialog, SWT.NONE);
    buttons.setLayout(new GridLayout(2, false));
    buttons.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, true, true));

    final Button buttonOK = new Button(buttons, SWT.PUSH);
    buttonOK.setText(TuxGuitar.getProperty("ok"));
    buttonOK.setLayoutData(getButtonData());
    buttonOK.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent arg0) {
            update(titleText.getText(), tagkeysText.getText(), descriptionText.getText());

            dialog.dispose();
          }
        });

    Button buttonCancel = new Button(buttons, SWT.PUSH);
    buttonCancel.setText(TuxGuitar.getProperty("cancel"));
    buttonCancel.setLayoutData(getButtonData());
    buttonCancel.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent arg0) {
            dialog.dispose();
          }
        });

    dialog.setDefaultButton(buttonOK);

    if (this.errors != null) {
      MessageDialog.errorMessage(dialog, this.errors);
    }
    DialogUtils.openDialog(
        dialog,
        DialogUtils.OPEN_STYLE_CENTER | DialogUtils.OPEN_STYLE_PACK | DialogUtils.OPEN_STYLE_WAIT);
  }
  private void drawWindow() {
    shell =
        new Shell(SWT.ON_TOP | SWT.APPLICATION_MODAL | SWT.TITLE | SWT.MIN | SWT.MAX | SWT.RESIZE);

    // Setup Title
    shell.setText("Artifact Information");

    // Setup Icon
    Image image = ArtifactImageManager.getImage(CoreArtifactTypes.Artifact);
    shell.setImage(image);

    // Setup Form Layout
    FormLayout layout = new FormLayout();
    layout.marginHeight = 5;
    layout.marginWidth = 5;
    shell.setLayout(layout);

    SashForm sashForm = new SashForm(shell, SWT.VERTICAL);

    // Create valid artifact fields
    FormLayout validLayout = new FormLayout();
    validLayout.spacing = 5;

    Composite validComposite = new Composite(sashForm, SWT.NONE);
    validComposite.setLayout(validLayout);

    Label validLabel = new Label(validComposite, SWT.LEFT);
    validLabel.setText("Valid artifacts - will be added");

    Table validTable =
        new Table(
            validComposite,
            SWT.MULTI
                | SWT.BORDER
                | SWT.H_SCROLL
                | SWT.V_SCROLL
                | SWT.FULL_SELECTION
                | SWT.HIDE_SELECTION);
    validTable.setLinesVisible(true);
    validTable.setHeaderVisible(true);

    // Create invalid artifacts fields
    FormLayout invalidLayout = new FormLayout();
    invalidLayout.spacing = 5;

    Composite invalidComposite = new Composite(sashForm, SWT.NONE);
    invalidComposite.setLayout(invalidLayout);

    Label invalidLabel = new Label(invalidComposite, SWT.LEFT);
    invalidLabel.setText("Invalid artifacts - will not be added");

    Table invalidTable =
        new Table(
            invalidComposite,
            SWT.MULTI
                | SWT.BORDER
                | SWT.H_SCROLL
                | SWT.V_SCROLL
                | SWT.FULL_SELECTION
                | SWT.HIDE_SELECTION);
    invalidTable.setLinesVisible(true);
    invalidTable.setHeaderVisible(true);

    // Create the Buttons
    Button okButton = new Button(invalidComposite, SWT.PUSH);
    okButton.setText("OK");

    Button cancelButton = new Button(invalidComposite, SWT.PUSH);
    cancelButton.setText("Cancel");

    // Attach validLabel to top-left corner
    FormData data = new FormData();
    data.top = new FormAttachment(0);
    data.left = new FormAttachment(0);
    validLabel.setLayoutData(data);

    // Attach validTable to bottom of validLabel
    data = new FormData();
    data.top = new FormAttachment(validLabel);
    data.bottom = new FormAttachment(100);
    data.left = new FormAttachment(0);
    data.right = new FormAttachment(100);
    data.height = validTable.getItemHeight() * 10;
    validTable.setLayoutData(data);

    // Attach invalidLabel to top-left corner
    data = new FormData();
    data.top = new FormAttachment(0);
    data.left = new FormAttachment(0);
    invalidLabel.setLayoutData(data);

    // Attach invalidTable to bottom of invalidLabel
    data = new FormData();
    data.top = new FormAttachment(invalidLabel);
    data.bottom = new FormAttachment(okButton);
    data.left = new FormAttachment(0);
    data.right = new FormAttachment(100);
    data.height = validTable.getItemHeight() * 10;
    invalidTable.setLayoutData(data);

    // Attach sashForm to top-left corner of shell
    data = new FormData();
    data.top = new FormAttachment(0);
    data.bottom = new FormAttachment(100);
    data.left = new FormAttachment(0);
    data.right = new FormAttachment(100);
    sashForm.setLayoutData(data);

    // Attach buttons to bottom of sashForm
    data = new FormData();
    data.bottom = new FormAttachment(100);
    data.right = new FormAttachment(100);
    cancelButton.setLayoutData(data);

    data = new FormData();
    data.bottom = new FormAttachment(100);
    data.right = new FormAttachment(cancelButton);
    okButton.setLayoutData(data);

    // Populate Tables
    relationTableViewer = new RelationTableViewer(validTable, invalidTable, branch);
    for (int i = 0; i < validArtifacts.size(); i++) {
      relationTableViewer.addValidItem(validArtifacts.get(i));
    }
    for (int i = 0; i < invalidName.size(); i++) {
      relationTableViewer.addInvalidItem(invalidName.get(i), invalidReason.get(i));
    }

    // Add Listeners to buttons
    okButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            okSelected();
          }
        });

    cancelButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            cancelSelected();
          }
        });

    // Add shell resize listener
    shell.addControlListener(
        new ControlListener() {

          @Override
          public void controlMoved(ControlEvent e) {
            // do nothing
          }

          @Override
          public void controlResized(ControlEvent e) {
            relationTableViewer.resizeTable(((Shell) e.widget).getClientArea().width);
            shell.layout();
          }
        });

    if (needWindow) {
      shell.pack();
      shell.open();
    } else {
      okSelected();
    }
  }
Ejemplo n.º 21
0
  /** *************************************************************** */
  private void creaContenidos() {
    display = new Display();
    shell = new Shell();

    // EN CASO DE NO RECUPERAR BIEN TOD0 EL CODIGO CNO browser.getText(); lo hacemos con el DOM
    // mediante JAVASCRIPT
    // System.out.println( (String)brw.evaluate("return document.forms[0].innerHTML;") );
    //
    // if ((Boolean)brw.evaluate("return raise('SelectFare', new SelectFareEventArgs(1, 1, 'G'));"))
    // System.out.println("raise() EJEC CORRECMT");;

    final String html =
        "<html><title>Snippet</title><body><p id='myid'>Best Friends</p><p id='myid2'>Cat and Dog</p></body></html>";
    // final String jsSelecValladolid = "var i=0; while(Stations[i]!=null){; i++;}";

    // Ej de jQuery que funciona: Devuelve el valor del listbox de "Origen Vuelo" selecionado
    final String jQueryRyan = "var orig=$(\"select[@id*='Origin1']\").val(); alert(orig);";
    // "$(\"select[@id*='Origin1']\")[posicion].attr('selected', 'true');";

    /** *** VARIABLES !!!VENTANA¡¡¡ **** */

    // SYSTEM TRAY
    Image image = null;
    try {
      // image = new Image(display, /*rutaActual*/"C:\\"+"fr.ico");
      image = new Image(display, rutaActual + "fr.ico");
    } catch (Exception e) {
      e.getMessage();
    }
    final Tray tray = display.getSystemTray();
    if (tray == null) {
      System.out.println("El system tray no está disponible");
    } else {
      final TrayItem item = new TrayItem(tray, SWT.NONE);
      item.setToolTipText("Ryanair Inspector v2");
      item.setImage(image);
      // Click simple en en icono
      item.addListener(
          SWT.Selection,
          new Listener() {
            public void handleEvent(Event event) {
              // System.out.println("selection");
            }
          });
      // Doble click en en icono
      item.addListener(
          SWT.DefaultSelection,
          new Listener() {
            public void handleEvent(Event event) {
              // System.out.println("default selection");
              // mio
              if (shell.getVisible()) shell.setVisible(false);
              else shell.setVisible(true);
              // shell.setMinimized(false);
              // shell.setMinimized(true);
            }
          });
    }

    // SHELL
    shell.setSize(1054, 727);
    // shell.setLayout(new FillLayout());
    shell.setText("Ryanair checker");
    shell.setImage(image);
    // Con esto al agrandar y empequeñecer se reorganizan los componentes
    // shell.setLayout(new FillLayout());

    // CREAMOS CONTENEDOR
    /** ************************************************************************ */
    compIzq = new Composite(shell, SWT.NONE);
    compIzq.setBounds(0, 0, 765, 691);
    final FillLayout fillLayout = new FillLayout(SWT.VERTICAL);
    fillLayout.marginWidth = 200;
    fillLayout.marginHeight = 200;
    // comp.setLayout(fillLayout);
    // comp.setSize(200, 200);

    compDer = new Composite(shell, SWT.NONE);
    compDer.setBounds(771, 0, 267, 691);

    // CREAMOS CAJA TEXTO Y BOTON PARA HTML OBTENIDO
    /** ************************************************************************ */
    final Text txtGetHTML = new Text(compDer, SWT.MULTI);
    txtGetHTML.setBounds(0, 0, 251, 198);

    // RyanairInspector2.class.getResource("RyanairInspector2.class").getPath();
    // System.getProperty("user.dir")+"\\bin\\calculadora\\";
    txtGetHTML.setText(
        RyanairInspector2.class.getResource("RyanairInspector2.class").getPath()
            + "\n"
            + System.getProperty("user.dir"));

    final Button button = new Button(compDer, SWT.NONE);
    button.setText("button");

    // TABS
    /** ************************************************************************ */
    tabFolder = new TabFolder(compIzq, SWT.BORDER);
    itemT1 = new TabItem(tabFolder, SWT.NONE);
    itemT2 = new TabItem(tabFolder, SWT.NONE);
    itemT3 = new TabItem(tabFolder, SWT.NONE);
    itemT1.setText("Resultado");
    itemT2.setText("Debugger");
    itemT3.setText("Hilos");

    // TABLE CON DOS COLUMNAS
    /** ************************************************************************ */
    table = new Table(tabFolder, SWT.VIRTUAL);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    final TableColumn column1 = new TableColumn(table, SWT.NONE);
    column1.setText("Origen");
    column1.setWidth(200);
    final TableColumn column2 = new TableColumn(table, SWT.NONE);
    column2.setText("Destino");
    column2.setWidth(200);
    final TableColumn column3 = new TableColumn(table, SWT.NONE);
    column3.setText("Fecha");
    column3.setWidth(200);
    final TableColumn column4 = new TableColumn(table, SWT.NONE);
    column4.setText("Precio");
    column4.setWidth(150);

    /* Metemos elementos en la tabla
    TableItem fila = new TableItem(table, SWT.NONE);
    fila.setText(new String[] { "a", "b", "c", "d" });
    */

    // METEMOS EL TABLE EN LA TAB2
    itemT1.setControl(table);
    tabFolder.setBounds(0, 0, 700, 691);
    tabFolder.pack();

    // CREAMOS BROWSER
    /** ************************************************************************ */
    try {
    } catch (SWTError e) {
      System.out.println("Could not instantiate Browser: " + e.getMessage());
      return;
    }
    // CREAMOS BROWSER (2)
    /** ************************************************************************ */
    // FUNCIONA BIEN SIN TABS: browser = new Browser(compIzq, SWT.BORDER);

    // El Normal
    navegadores.add(new Navegador(tabFolder, SWT.BORDER));
    // El Mozilla (hay q ejecutar el xulrunner.exe --register-global)
    // browser = new Browser(tabFolder, SWT.MOZILLA);
    // browser.setSize(1000, 800);
    navegadores.get(0).setBounds(0, 0, 787, 691);
    // browser.setLocation(500, 900);
    /*final FillLayout fillLayoutB = new FillLayout(SWT.VERTICAL);
    fillLayoutB.marginWidth = 200;
    fillLayoutB.marginHeight = 200;
    browser.setLayout(fillLayoutB);
     */

    // METEMOS EL BROWSER EN LA TAB1
    itemT2.setControl(navegadores.get(0)); // prueba18-6-09
    // browser.setVisible(false);

    tabFolder.setBounds(0, 0, 766, 691);
    tabFolder.pack();

    navegadores.add(new Navegador(tabFolder, SWT.BORDER));
    navegadores.get(1).setBounds(0, 0, 787, 691);
    itemT3.setControl(navegadores.get(1));

    // CADA VEZ!!! QUE TERMINE DE CARGAR
    navegadores
        .get(0)
        .addProgressListener(
            new ProgressAdapter() {
              public void completed(ProgressEvent event) {
                if (!postSubmit(navegadores.get(0), table)) {
                  System.out.println(
                      "ERROR: Problema al ejecutar la gestion de los datos, finalizar la carga de la pagina.");
                }
              }
            });

    // CADA VEZ!!! QUE TERMINE DE CARGAR
    navegadores
        .get(1)
        .addProgressListener(
            new ProgressAdapter() {
              public void completed(ProgressEvent event) {
                if (!postSubmit(navegadores.get(1), table)) {
                  System.out.println(
                      "ERROR: Problema al ejecutar la gestion de los datos, finalizar la carga de la pagina.");
                }
              }
            });

    // BOTON OBTENER HTML
    /** ************************************************************************ */
    final Button btnGetHTML = new Button(compDer, SWT.PUSH);
    btnGetHTML.setBounds(0, 204, 151, 30);
    btnGetHTML.setText("Obtener codigo html");
    btnGetHTML.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event event) {

            addBrowser();

            String result = navegadores.get(0).getText();
            txtGetHTML.setText(result);
          }
        });

    // CREAMOS CAJA TEXTO PARA EJECUTAR JS
    /** ************************************************************************ */
    /*final Text txtJS = new Text(compDer, SWT.MULTI);
    txtJS.setText("var newNode = document.createElement('P'); \r\n"+
    		"var text = document.createTextNode('At least when I am around');\r\n"+
    		"newNode.appendChild(text);\r\n"+
    		"document.getElementById('myid').appendChild(newNode);\r\n"+
    		"document.bgColor='yellow';\r\n"+
    		"\r\n"+
    		"document.getElementById('AvailabilitySearchInputFRSearchView_OneWay').checked = true;\r\n"+
    		"document.getElementById('AvailabilitySearchInputFRSearchView_ButtonSubmit').click();\r\n"+
    		"document.getElementById('AvailabilitySearchInputFRSearchView_DropDownListMarketOrigin1')[2].selected=true;\r\n"+
    		"Destination1");
    */

    // BOTON LANZAMOS RYANAIR
    /** ************************************************************************ */
    /*final Button btnCargarRyan = new Button(compDer, SWT.PUSH);
    btnCargarRyan.setText("Cargar RYANAIR");
    btnCargarRyan.addListener(SWT.Selection, new Listener() {
    	public void handleEvent(Event event) {
    		//boolean result = browser.execute(text.getText());
    		boolean result = browser.setUrl("http://www.bookryanair.com/SkySales/FRSearch.aspx?culture=ES-ES&pos=HEAD");
    		if (!result) {
    			// Script may fail or may not be supported on certain platforms.
    			System.out.println("Script was not executed.");
    		}
    	}
    });
    */

    // BOTON EJECUTAMOS JAVASCRIPT
    /** ************************************************************************ */
    final Button btnEjeJS = new Button(compDer, SWT.PUSH);
    btnEjeJS.setBounds(0, 266, 151, 30);
    btnEjeJS.setText("Ejecutar JAVASCRIPT");
    btnEjeJS.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event event) {}
        });

    // image.dispose(); //con esto no funciona el shell.setImage(image)

  }
Ejemplo n.º 22
0
 @Override
 protected void configureShell(Shell shell) {
   super.configureShell(shell);
   shell.setText("Symbol File");
   shell.setImage(image);
 }
  public SAPFunction open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();
    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX);
    props.setLook(shell);
    shell.setImage(GUIResource.getInstance().getImageSpoon());
    int middle = Const.MIDDLE_PCT;
    int margin = Const.MARGIN;

    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;

    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "SapFunctionBrowser.Title"));

    // Function
    //
    wlFunction = new Label(shell, SWT.RIGHT);
    wlFunction.setText(BaseMessages.getString(PKG, "SapInputDialog.Function.Label"));
    props.setLook(wlFunction);
    FormData fdlFunction = new FormData();
    fdlFunction.left = new FormAttachment(0, 0);
    fdlFunction.right = new FormAttachment(middle, -margin);
    fdlFunction.top = new FormAttachment(0, 0);
    wlFunction.setLayoutData(fdlFunction);
    wbFunction = new Button(shell, SWT.PUSH);
    props.setLook(wbFunction);

    wbFunction.setText(BaseMessages.getString(PKG, "SapInputDialog.FindFunctionButton.Label"));
    FormData fdbFunction = new FormData();
    fdbFunction.right = new FormAttachment(100, 0);
    fdbFunction.top = new FormAttachment(0, 0);
    wbFunction.setLayoutData(fdbFunction);
    wbFunction.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            searchString = wFunction.getText();
            getData();
          }
        });

    wFunction = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wFunction);
    FormData fdFunction = new FormData();
    fdFunction.left = new FormAttachment(middle, 0);
    fdFunction.right = new FormAttachment(wbFunction, -margin);
    fdFunction.top = new FormAttachment(0, margin);
    wFunction.setLayoutData(fdFunction);
    Control lastControl = wFunction;

    // The buttons at the bottom of the dialog
    //
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    wOK.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            ok();
          }
        });
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    wCancel.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            cancel();
          }
        });

    // Position the buttons...
    //
    BaseStepDialog.positionBottomButtons(
        shell,
        new Button[] {
          wOK, wCancel,
        },
        Const.MARGIN,
        null);

    // The search results...
    //
    ColumnInfo[] columns =
        new ColumnInfo[] {
          new ColumnInfo(
              BaseMessages.getString(PKG, "SapFunctionBrowser.ResultView.Name.Column"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false,
              true),
          new ColumnInfo(
              BaseMessages.getString(PKG, "SapFunctionBrowser.ResultView.Groupname.Column"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false,
              true),
          new ColumnInfo(
              BaseMessages.getString(PKG, "SapFunctionBrowser.ResultView.Application.Column"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false,
              true),
          new ColumnInfo(
              BaseMessages.getString(PKG, "SapFunctionBrowser.ResultView.Description.Column"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false,
              true),
        };

    wResult =
        new TableView(
            space, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, columns, 0, null, props);
    wResult.setSortable(true);

    FormData fdResults = new FormData();
    fdResults.left = new FormAttachment(0, 0);
    fdResults.top = new FormAttachment(lastControl, margin);
    fdResults.right = new FormAttachment(100, 0);
    fdResults.bottom = new FormAttachment(wOK, -3 * margin);
    wResult.setLayoutData(fdResults);

    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(
        new ShellAdapter() {
          public void shellClosed(ShellEvent e) {
            cancel();
          }
        });

    getData();

    // Set the shell size, based upon previous time...
    BaseStepDialog.setSize(shell);

    shell.open();

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }

    return function;
  }
Ejemplo n.º 24
0
  /**
   * Create the composite.
   *
   * @param parent
   * @param style
   */
  public ArgumentsDialog(
      final Shell parent, ExecutionConfiguration configuration, AbstractMeta abstractMeta) {
    super(parent);
    this.configuration = configuration;

    display = parent.getDisplay();
    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.MIN | SWT.APPLICATION_MODAL);
    props = PropsUI.getInstance();
    props.setLook(shell);
    shell.setImage(parent.getImage());
    shell.setLayout(new FormLayout());
    shell.setText(BaseMessages.getString(PKG, "ArgumentsDialog.Arguments.Label"));

    ColumnInfo[] cArguments = {
      new ColumnInfo(
          BaseMessages.getString(PKG, "ArgumentsDialog.ArgumentsColumn.Argument"),
          ColumnInfo.COLUMN_TYPE_TEXT,
          false,
          true,
          180), // Argument name
      new ColumnInfo(
          BaseMessages.getString(PKG, "ArgumentsDialog.ArgumentsColumn.Value"),
          ColumnInfo.COLUMN_TYPE_TEXT,
          false,
          false,
          172), // Actual value
    };

    int nrArguments =
        configuration.getArguments() != null ? configuration.getArguments().size() : 0;

    wArguments =
        new TableView(
            abstractMeta,
            shell,
            SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI,
            cArguments,
            nrArguments,
            false,
            null,
            props,
            false);

    FormData fd_argumentsTable = new FormData();
    fd_argumentsTable.top = new FormAttachment(0, 15);
    fd_argumentsTable.left = new FormAttachment(0, 15);
    fd_argumentsTable.bottom = new FormAttachment(0, 221);
    fd_argumentsTable.right = new FormAttachment(0, 371);
    wArguments.setLayoutData(fd_argumentsTable);

    Label separator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
    FormData fd_separator = new FormData();
    fd_separator.top = new FormAttachment(wArguments, 15);
    fd_separator.right = new FormAttachment(wArguments, 0, SWT.RIGHT);
    fd_separator.left = new FormAttachment(0, 15);
    separator.setLayoutData(fd_separator);

    Button okButton = new Button(shell, SWT.NONE);
    okButton.setText("OK");
    FormData fd_okButton = new FormData();
    fd_okButton.left = new FormAttachment(0, 269);
    okButton.setLayoutData(fd_okButton);
    okButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            ok();
          }
        });

    Button cancelButton = new Button(shell, SWT.NONE);
    fd_okButton.top = new FormAttachment(cancelButton, 0, SWT.TOP);
    fd_okButton.right = new FormAttachment(cancelButton, -4);
    cancelButton.setText("Cancel");
    FormData fd_cancelButton = new FormData();
    fd_cancelButton.top = new FormAttachment(separator, 13);
    fd_cancelButton.right = new FormAttachment(wArguments, 0, SWT.RIGHT);
    cancelButton.setLayoutData(fd_cancelButton);
    cancelButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            dispose();
          }
        });

    Button btnHelp = new Button(shell, SWT.NONE);
    btnHelp.setImage(GUIResource.getInstance().getImageHelpWeb());
    btnHelp.setText(BaseMessages.getString(PKG, "System.Button.Help"));
    btnHelp.setToolTipText(BaseMessages.getString(PKG, "System.Tooltip.Help"));
    FormData fd_btnHelp = new FormData();
    fd_btnHelp.top = new FormAttachment(separator, 13);
    fd_btnHelp.left = new FormAttachment(separator, 0, SWT.LEFT);
    btnHelp.setLayoutData(fd_btnHelp);
    btnHelp.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent evt) {
            String docUrl = BaseMessages.getString(Spoon.class, "Spoon.ArgumentsDialog.Help");
            String docTitle = BaseMessages.getString(PKG, "ArgumentsDialog.docTitle");
            String docHeader = BaseMessages.getString(PKG, "ArgumentsDialog.docHeader");
            HelpUtils.openHelpDialog(parent.getShell(), docTitle, docUrl, docHeader);
          }
        });

    shell.setSize(394, 319);
    getArgumentsData();
    shell.open();

    Rectangle shellBounds = getParent().getBounds();
    Point dialogSize = shell.getSize();

    shell.setLocation(
        shellBounds.x + (shellBounds.width - dialogSize.x) / 2,
        shellBounds.y + (shellBounds.height - dialogSize.y) / 2);

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
  }
Ejemplo n.º 25
0
  public DeleteContentsDialog(Browser _browser, String domain, String[] _ids, String[] titles) {
    this.domain = domain;
    this.browser = _browser;
    this.ids = _ids;
    shell = new Shell(browser.getShell(), SWT.CLOSE | SWT.RESIZE | SWT.APPLICATION_MODAL);
    ClientRM clientRM = DeleteDomainPlugin.getResources();
    ApplicationFactory factory = new ApplicationFactory(shell, clientRM, getClass().getName());
    shell.setText(factory.getLabel("title"));
    factory.setComposite(shell);
    shell.setLayout(new GridLayout(1, false));

    shell.addShellListener(
        new ShellAdapter() {
          public void shellClosed(ShellEvent e) {
            new ShellSetter(DeleteContentsDialog.class, shell);
            shell.dispose();
          }
        });

    factory.setComposite(shell);

    RefsDecoder decoder = new RefsDecoder();

    butTitles = new Button[titles.length];
    //    selectors = new DeleteSingleArticleSelector[10];
    for (int i = 0; i < butTitles.length; i++) {
      titles[i] = new String(decoder.decode(titles[i].toCharArray()));
      butTitles[i] = new Button(shell, SWT.CHECK);
      butTitles[i].setSelection(true);
      butTitles[i].setToolTipText(clientRM.getLabel("itemDeleteTooltip"));
      butTitles[i].setText(titles[i]);
      butTitles[i].setLayoutData(new GridData());
    }

    Composite bottom = new Composite(shell, SWT.NONE);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    // gridData.horizontalSpan = 2;
    bottom.setLayoutData(gridData);
    RowLayout rowLayout = new RowLayout();
    bottom.setLayout(rowLayout);
    rowLayout.justify = true;
    factory.setComposite(bottom);

    factory.createButton(
        "butDeletDomain",
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent evt) {
            deleteDomain();
          }
        });

    SelectionAdapter syncListener =
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent evt) {
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < ids.length; i++) {
              if (!butTitles[i].getSelection()) continue;
              if (builder.length() > 0) builder.append('\n');
              builder.append(ids[i]);
            }
            DeleteContentPlugin.delete(browser, builder.toString());
            shell.dispose();
          }
        };

    factory.createButton("butOk", syncListener);

    factory.createButton(
        "butClose",
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent evt) {
            new ShellSetter(DeleteContentsDialog.class, shell);
            shell.dispose();
          }
        });

    Rectangle displayRect = UIDATA.DISPLAY.getBounds();
    int x = (displayRect.width - 350) / 2;
    int y = (displayRect.height - 300) / 2;
    shell.setImage(browser.getShell().getImage());
    new ShellGetter(DeleteContentsDialog.class, shell, 550, 350, x, y);
    shell.open();
  }
Ejemplo n.º 26
0
  public Splash(Display display) throws KettleException {
    log = new LogChannel(Spoon.APP_NAME);

    Rectangle displayBounds = display.getPrimaryMonitor().getBounds();

    kettle_image =
        ImageUtil.getImageAsResource(
            display,
            BasePropertyHandler.getProperty("splash_image")); // "kettle_splash.png" //$NON-NLS-1$
    kettle_icon =
        ImageUtil.getImageAsResource(
            display, BasePropertyHandler.getProperty("splash_icon")); // "spoon.ico" //$NON-NLS-1$
    exclamation_image =
        ImageUtil.getImageAsResource(
            display,
            BasePropertyHandler.getProperty(
                "exclamation_image")); // "exclamation.png" //$NON-NLS-1$

    verFont = new Font(display, "Helvetica", 11, SWT.BOLD); // $NON-NLS-1$
    licFont = new Font(display, "Helvetica", licFontSize, SWT.NORMAL); // $NON-NLS-1$
    devWarningFont = new Font(display, "Helvetica", 10, SWT.NORMAL); // $NON-NLS-1$

    versionWarningBackgroundColor = new Color(display, 255, 253, 213);
    versionWarningForegroundColor = new Color(display, 220, 177, 20);

    splash = new Shell(display, SWT.APPLICATION_MODAL);
    splash.setImage(kettle_icon);

    splash.setText(
        BaseMessages.getString(
            PKG, "SplashDialog.Title")); // "Pentaho Data Integration" //$NON-NLS-1$

    FormLayout splashLayout = new FormLayout();
    splash.setLayout(splashLayout);

    Canvas canvas = new Canvas(splash, SWT.NO_BACKGROUND);

    FormData fdCanvas = new FormData();
    fdCanvas.left = new FormAttachment(0, 0);
    fdCanvas.top = new FormAttachment(0, 0);
    fdCanvas.right = new FormAttachment(100, 0);
    fdCanvas.bottom = new FormAttachment(100, 0);
    canvas.setLayoutData(fdCanvas);

    canvas.addPaintListener(
        new PaintListener() {
          public void paintControl(PaintEvent e) {
            String versionText =
                BaseMessages.getString(PKG, "SplashDialog.Version")
                    + " "
                    + Const.VERSION; // $NON-NLS-1$ //$NON-NLS-2$

            StringBuilder sb = new StringBuilder();
            String line = null;

            try {
              BufferedReader reader =
                  new BufferedReader(
                      new InputStreamReader(
                          Splash.class
                              .getClassLoader()
                              .getResourceAsStream(
                                  "org/pentaho/di/ui/core/dialog/license/license.txt"))); //$NON-NLS-1$

              while ((line = reader.readLine()) != null) {
                sb.append(line + System.getProperty("line.separator")); // $NON-NLS-1$
              }
            } catch (Exception ex) {
              sb.append(""); // $NON-NLS-1$
              log.logError(
                  BaseMessages.getString(PKG, "SplashDialog.LicenseTextNotFound"),
                  ex); //$NON-NLS-1$
            }
            Calendar cal = Calendar.getInstance();
            String licenseText = String.format(sb.toString(), cal);
            e.gc.drawImage(kettle_image, 0, 0);

            // If this is a Milestone or RC release, warn the user
            if (Const.RELEASE.equals(Const.ReleaseType.MILESTONE)) {
              versionText =
                  BaseMessages.getString(PKG, "SplashDialog.DeveloperRelease")
                      + " - "
                      + versionText; //$NON-NLS-1$ //$NON-NLS-2$
              drawVersionWarning(e);
            } else if (Const.RELEASE.equals(Const.ReleaseType.RELEASE_CANDIDATE)) {
              versionText =
                  BaseMessages.getString(PKG, "SplashDialog.ReleaseCandidate")
                      + " - "
                      + versionText; //$NON-NLS-1$//$NON-NLS-2$
            } else if (Const.RELEASE.equals(Const.ReleaseType.PREVIEW)) {
              versionText =
                  BaseMessages.getString(PKG, "SplashDialog.PreviewRelease")
                      + " - "
                      + versionText; //$NON-NLS-1$//$NON-NLS-2$
            } else if (Const.RELEASE.equals(Const.ReleaseType.GA)) {
              versionText =
                  BaseMessages.getString(PKG, "SplashDialog.GA")
                      + " - "
                      + versionText; //$NON-NLS-1$//$NON-NLS-2$
            }

            e.gc.setFont(verFont);
            e.gc.drawText(versionText, 290, 205, true);

            // try using the desired font size for the license text
            e.gc.setFont(licFont);

            // if the text will not fit the allowed space
            while (!willLicenseTextFit(licenseText, e.gc)) {
              licFontSize--;
              if (licFont != null) {
                licFont.dispose();
              }
              licFont = new Font(e.display, "Helvetica", licFontSize, SWT.NORMAL); // $NON-NLS-1$
              e.gc.setFont(licFont);
            }

            e.gc.drawText(licenseText, 290, 290, true);
          }
        });

    splash.addDisposeListener(
        new DisposeListener() {
          public void widgetDisposed(DisposeEvent arg0) {
            kettle_image.dispose();
            kettle_icon.dispose();
            exclamation_image.dispose();
            verFont.dispose();
            licFont.dispose();
            devWarningFont.dispose();
            versionWarningForegroundColor.dispose();
            versionWarningBackgroundColor.dispose();
          }
        });
    Rectangle bounds = kettle_image.getBounds();
    int x = (displayBounds.width - bounds.width) / 2;
    int y = (displayBounds.height - bounds.height) / 2;

    splash.setSize(bounds.width, bounds.height);
    splash.setLocation(x, y);

    splash.open();
  }
Ejemplo n.º 27
0
  public RenameDialog(Shell parent, SourcesHandler handler, CopySource copy) {
    dialog = new Shell(parent, SWT.DIALOG_TRIM | SWT.CLOSE | SWT.APPLICATION_MODAL);
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = 10;
    formLayout.marginHeight = 10;
    formLayout.spacing = 10;
    dialog.setLayout(formLayout);

    this.copySource = copy;
    this.handler = handler;

    ApplicationFactory factory = new ApplicationFactory(dialog, "Creator", getClass().getName());

    Label label = factory.createLabel("name"); // new Label (dialog, SWT.NONE);
    FormData data = new FormData();
    label.setLayoutData(data);

    Button cancel = factory.createButton("cancel");
    data = new FormData();
    data.width = 60;
    data.right = new FormAttachment(100, 0);
    data.bottom = new FormAttachment(100, 0);
    cancel.setLayoutData(data);
    cancel.addSelectionListener(
        new SelectionAdapter() {
          @SuppressWarnings("unused")
          public void widgetSelected(SelectionEvent e) {
            dialog.close();
          }
        });

    final Text text = new Text(dialog, SWT.BORDER);
    text.setText(copySource.getSrcNames()[0]);
    data = new FormData();
    data.width = 200;
    data.left = new FormAttachment(label, 0, SWT.DEFAULT);
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(label, 0, SWT.CENTER);
    data.bottom = new FormAttachment(cancel, 0, SWT.DEFAULT);
    text.setLayoutData(data);

    Button ok = new Button(factory.getComposite(), SWT.PUSH);
    ;
    ok.setText("Ok");
    data = new FormData();
    data.width = 60;
    data.right = new FormAttachment(cancel, 0, SWT.DEFAULT);
    data.bottom = new FormAttachment(100, 0);
    ok.setLayoutData(data);
    ok.addSelectionListener(
        new SelectionAdapter() {
          @SuppressWarnings("unused")
          public void widgetSelected(SelectionEvent e) {
            rename(text.getText());
          }
        });

    Rectangle displayRect = UIDATA.DISPLAY.getBounds();
    int x = (displayRect.width - 350) / 2;
    int y = (displayRect.height - 300) / 2;
    dialog.setImage(parent.getImage());
    dialog.setLocation(x, y);

    dialog.setDefaultButton(ok);
    dialog.pack();
    //    XPWindowTheme.setWin32Theme(dialog);
    dialog.open();
  }
  public void open() {
    shell = new Shell(parentShell, style);
    props.setLook(shell);
    shell.setImage(GUIResource.getInstance().getImageSpoon());

    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;

    if (title == null) title = BaseMessages.getString(PKG, "PreviewRowsDialog.Title");
    if (message == null)
      message = BaseMessages.getString(PKG, "PreviewRowsDialog.Header", stepname);

    if (buffer != null)
      message += " " + BaseMessages.getString(PKG, "PreviewRowsDialog.NrRows", "" + buffer.size());

    shell.setLayout(formLayout);
    shell.setText(title);

    if (addFields()) {
      return;
    }

    List<Button> buttons = new ArrayList<Button>();

    wClose = new Button(shell, SWT.PUSH);
    wClose.setText(BaseMessages.getString(PKG, "System.Button.Close"));
    wClose.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            close();
          }
        });
    buttons.add(wClose);

    if (!Const.isEmpty(loggingText)) {
      wLog = new Button(shell, SWT.PUSH);
      wLog.setText(BaseMessages.getString(PKG, "PreviewRowsDialog.Button.ShowLog"));
      wLog.addListener(
          SWT.Selection,
          new Listener() {
            public void handleEvent(Event e) {
              log();
            }
          });
      buttons.add(wLog);
    }

    if (proposingToStop) {
      wStop = new Button(shell, SWT.PUSH);
      wStop.setText(BaseMessages.getString(PKG, "PreviewRowsDialog.Button.Stop.Label"));
      wStop.setToolTipText(BaseMessages.getString(PKG, "PreviewRowsDialog.Button.Stop.ToolTip"));
      wStop.addListener(
          SWT.Selection,
          new Listener() {
            public void handleEvent(Event e) {
              askingToStop = true;
              close();
            }
          });
      buttons.add(wStop);
    }

    if (proposingToGetMoreRows) {
      wNext = new Button(shell, SWT.PUSH);
      wNext.setText(BaseMessages.getString(PKG, "PreviewRowsDialog.Button.Next.Label"));
      wNext.setToolTipText(BaseMessages.getString(PKG, "PreviewRowsDialog.Button.Next.ToolTip"));
      wNext.addListener(
          SWT.Selection,
          new Listener() {
            public void handleEvent(Event e) {
              askingForMoreRows = true;
              close();
            }
          });
      buttons.add(wNext);
    }

    if (proposingToGetMoreRows || proposingToStop) {
      wClose.setText(BaseMessages.getString(PKG, "PreviewRowsDialog.Button.Close.Label"));
      wClose.setToolTipText(BaseMessages.getString(PKG, "PreviewRowsDialog.Button.Close.ToolTip"));
    }

    // Position the buttons...
    //
    BaseStepDialog.positionBottomButtons(
        shell, buttons.toArray(new Button[buttons.size()]), Const.MARGIN, null);

    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(
        new ShellAdapter() {
          public void shellClosed(ShellEvent e) {
            close();
          }
        });

    getData();

    BaseStepDialog.setSize(shell);

    shell.open();

    if (!waitingForRows) {
      while (!shell.isDisposed()) {
        if (!shell.getDisplay().readAndDispatch()) shell.getDisplay().sleep();
      }
    }
  }
Ejemplo n.º 29
0
 public void setImage(Image image) {
   shell.setImage(image);
 }
Ejemplo n.º 30
0
 /** @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) */
 protected void configureShell(Shell shell) {
   super.configureShell(shell, 0, 0);
   shell.setText(getText("_UI_CompPropertyDialog_title"));
   shell.setImage(lblProvider.getImage(object));
 }