Esempio n. 1
0
  public TreeSources(ApplicationFactory factory, Composite parent) {
    super(parent);

    setLayout(new FillLayout());

    tree = factory.createTree(this, SWT.MULTI);
    tree.setLinesVisible(false);

    createMenu(tree, factory);

    tree.addMouseListener(
        new MouseAdapter() {
          @SuppressWarnings("unused")
          public void mouseDown(MouseEvent arg0) {
            clickMouse = true;
          }
        });

    tree.addTreeListener(
        new TreeAdapter() {
          @SuppressWarnings("unused")
          public void treeCollapsed(TreeEvent arg0) {
            clickMouse = false;
          }

          @SuppressWarnings("unused")
          public void treeExpanded(TreeEvent arg0) {
            clickMouse = false;
          }
        });

    tree.addSelectionListener(
        new SelectionAdapter() {
          @SuppressWarnings("unused")
          public void widgetSelected(SelectionEvent event) {
            if (!clickMouse) return;
            clickMouse = false;
            if (tree.getSelectionCount() < 1) return;
            TreeItem selectedItem = tree.getSelection()[0];
            TreeItem parentItem = selectedItem.getParentItem();
            if (parentItem == null) {
              new LoadGroupCategorySource(
                  TreeSources.this, new Worker[0], null, selectedItem.getText());
              creator.selectData(new Worker[0], null, selectedItem.getText());
              return;
            }

            String category = parentItem.getText();
            String name = selectedItem.getText();
            creator.setSource(null, category, name, false);
          }
        });
  }
Esempio n. 2
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();
  }
Esempio n. 3
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();
  }
Esempio n. 4
0
  private void initIcons(ApplicationFactory factory) {
    Composite center = null;
    if (Application.LICENSE == Install.PERSONAL) {
      center = new Composite(this, SWT.TRANSPARENCY_ALPHA);
      GridData gridData = new GridData(GridData.FILL_BOTH);
      center.setLayoutData(gridData);

      GridLayout gridLayout = new GridLayout(2, false);
      center.setLayout(gridLayout);

      Browser widget = null;

      //      ClientLog.getInstance().setMessage(getShell(), new Exception( "buoc 1 da chay vao day
      // roi " + widget.toString()));

      try {
        widget = new Browser(center, SWT.NONE);
        //        ClientLog.getInstance().setMessage(getShell(), new Exception( " da chay vao day
        // roi " + widget.toString()));
      } catch (Exception e) {
        widget = new Browser(center, SWT.NONE);
        ClientLog.getInstance().setException(null, e);
      }
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.verticalSpan = 2;
      widget.setLayoutData(gridData);
      if (Application.GROUPS.length > 0 && Application.GROUPS[0].equals("XML")) {
        widget.setUrl("http://vietspider.org/webextractor/");
        toolbar.setText("http://vietspider.org/webextractor/");
      } else {
        widget.setUrl("http://nik.vn/tin/");
        //      widget.setUrl("http://*****:*****@SuppressWarnings("unused")
          public void linkActivated(HyperlinkEvent e) {
            BrowserWidget browser = workspace.getTab().createItem();
            browser.viewPage();
          }
        };
    browserImageLink.addHyperlinkListener(listener);
    //    browserLink.addHyperlinkListener(listener);

    composite = createItem(top);
    final ImageHyperlink creatorImageLink =
        new ImageHyperlink(composite, SWT.CENTER | SWT.TRANSPARENCY_ALPHA);
    creatorImageLink.setImage(factory.loadImage("large.createsource.png"));
    //    creatorImageLink.setBackground(getBackground());
    creatorImageLink.setToolTipText(factory.getLabel("creatorLink"));
    //    final Hyperlink creatorLink = createLink(composite);
    //    creatorLink.setText(factory.getLabel("creatorLink"));
    //    creatorLink.setForeground(color);
    listener =
        new HyperlinkAdapter() {
          @SuppressWarnings("unused")
          public void linkEntered(HyperlinkEvent e) {
            //        creatorLink.setUnderlined(true);
          }

          @SuppressWarnings("unused")
          public void linkExited(HyperlinkEvent e) {
            //        creatorLink.setUnderlined(false);
          }

          @SuppressWarnings("unused")
          public void linkActivated(HyperlinkEvent e) {
            //        creatorLink.setUnderlined(false);
            try {
              ChannelWizard wizard =
                  (ChannelWizard)
                      workspace.getTab().createTool(ChannelWizard.class, false, SWT.CLOSE);
            } catch (Exception exp) {
              ClientLog.getInstance().setException(null, exp);
            }
            //        try {
            //          Creator creator = (Creator)workspace.getTab().createTool(
            //              Creator.class, false,  SWT.CLOSE);
            //          creator.selectData(new Worker[0], null, null);
            //        } catch (Exception exp) {
            //          ClientLog.getInstance().setException(null, exp);
            //        }
          }
        };
    creatorImageLink.addHyperlinkListener(listener);
    //    creatorLink.addHyperlinkListener(listener);

    ////////////////////////////////////////////////////////////////////////////////////////////////

    Composite bottom = new Composite(center, SWT.TRANSPARENCY_ALPHA);
    if (Application.LICENSE == Install.PERSONAL) {
      gridData = new GridData();
      gridData.widthHint = 350;
    } else {
      gridData = new GridData(GridData.FILL_BOTH);
    }
    bottom.setLayoutData(gridData);
    //    bottom.setBackground(getBackground());

    rowLayout = new RowLayout();
    rowLayout.wrap = true;
    rowLayout.pack = true;
    rowLayout.justify = true;
    rowLayout.type = SWT.HORIZONTAL;
    rowLayout.marginLeft = 5;
    rowLayout.marginTop = 5;
    rowLayout.marginRight = 5;
    rowLayout.marginBottom = 5;
    rowLayout.spacing = 20;
    bottom.setLayout(rowLayout);

    if (Application.LICENSE != Install.PERSONAL) {
      composite = createItem(top);
    } else {
      composite = createItem(bottom);
    }
    final ImageHyperlink crawlerImageLink =
        new ImageHyperlink(composite, SWT.CENTER | SWT.TRANSPARENCY_ALPHA);
    crawlerImageLink.setImage(factory.loadImage("large.crawler.png"));
    //    crawlerImageLink.setBackground(getBackground());
    crawlerImageLink.setToolTipText(factory.getLabel("crawlerLink"));
    //    final Hyperlink crawlerLink = createLink(composite);
    //    crawlerLink.setText(factory.getLabel("crawlerLink"));
    //    crawlerLink.setForeground(color);
    listener =
        new HyperlinkAdapter() {
          @SuppressWarnings("unused")
          public void linkEntered(HyperlinkEvent e) {
            //        crawlerLink.setUnderlined(true);
          }

          @SuppressWarnings("unused")
          public void linkExited(HyperlinkEvent e) {
            //        crawlerLink.setUnderlined(false);
          }

          @SuppressWarnings("unused")
          public void linkActivated(HyperlinkEvent e) {
            //        crawlerLink.setUnderlined(false);
            try {
              workspace.getTab().createTool(Crawler.class, true, SWT.CLOSE);
            } catch (Exception exp) {
              ClientLog.getInstance().setException(getShell(), exp);
            }
          }
        };
    crawlerImageLink.addHyperlinkListener(listener);
    //    crawlerLink.addHyperlinkListener(listener);

    if (Application.LICENSE != Install.PERSONAL) {
      composite = createItem(bottom);
      final ImageHyperlink monitorImageLink =
          new ImageHyperlink(composite, SWT.CENTER | SWT.TRANSPARENCY_ALPHA);
      monitorImageLink.setImage(factory.loadImage("large.log.png"));
      //      monitorImageLink.setBackground(getBackground());
      monitorImageLink.setToolTipText(factory.getLabel("logLink"));
      //      final Hyperlink monitorLink = createLink(composite);
      //      monitorLink.setText(factory.getLabel("monitorLink"));
      //      monitorLink.setForeground(color);
      listener =
          new HyperlinkAdapter() {
            @SuppressWarnings("unused")
            public void linkActivated(HyperlinkEvent e) {
              try {
                workspace.getTab().createTool(LogViewer2.class, true, SWT.CLOSE);
              } catch (Exception exp) {
                ClientLog.getInstance().setException(workspace.getShell(), exp);
              }
            }
          };
      monitorImageLink.addHyperlinkListener(listener);
      //      monitorLink.addHyperlinkListener(listener);
    }

    /*if(Application.LICENSE  != Install.PERSONAL) {
          composite = createItem(bottom);
          final ImageHyperlink userImageLink =
            new ImageHyperlink(composite, SWT.CENTER | SWT.TRANSPARENCY_ALPHA);
          userImageLink.setImage(factory.loadImage("large.userfolder.png"));
    //      userImageLink.setBackground(getBackground());
          userImageLink.setToolTipText(factory.getLabel("userLink"));
    //      final Hyperlink userLink = createLink(composite);
    //      userLink.setText(factory.getLabel("userLink"));
    //      userLink.setForeground(color);
          listener = new HyperlinkAdapter() {
            @SuppressWarnings("unused")
            public void linkEntered(HyperlinkEvent e) {
    //          userLink.setUnderlined(true);
            }

            @SuppressWarnings("unused")
            public void linkExited(HyperlinkEvent e) {
    //          userLink.setUnderlined(false);
    //          userLink.setFont(UIDATA.FONT_9VB);
            }
            @SuppressWarnings("unused")
            public void linkActivated(HyperlinkEvent e) {
    //          userLink.setUnderlined(false);
              try {
                workspace.getTab().createTool(Organization.class, true,  SWT.CLOSE);
              }catch (Exception exp) {
                ClientLog.getInstance().setException(workspace.getShell(), exp);
              }
            }
          };
          userImageLink.addHyperlinkListener(listener);
    //      userLink.addHyperlinkListener(listener);
        }*/

    composite = createItem(bottom);

    final ImageHyperlink configImageLink =
        new ImageHyperlink(composite, SWT.CENTER | SWT.TRANSPARENCY_ALPHA);
    configImageLink.setImage(factory.loadImage("large.settingsfolder.png"));
    //    configImageLink.setBackground(getBackground());
    configImageLink.setToolTipText(factory.getLabel("configLink"));
    //    final Hyperlink configLink = createLink(composite);
    //    configLink.setText(factory.getLabel("configLink"));
    //    configLink.setForeground(color);
    listener =
        new HyperlinkAdapter() {
          @SuppressWarnings("unused")
          public void linkEntered(HyperlinkEvent e) {
            //        configLink.setUnderlined(true);
          }

          @SuppressWarnings("unused")
          public void linkExited(HyperlinkEvent e) {
            //        configLink.setUnderlined(false);
          }

          @SuppressWarnings("unused")
          public void linkActivated(HyperlinkEvent e) {
            //        configLink.setUnderlined(false);
            try {
              workspace.getTab().createTool(Config.class, true, SWT.CLOSE);
            } catch (Exception exp) {
              ClientLog.getInstance().setException(workspace.getShell(), exp);
            }
          }
        };
    configImageLink.addHyperlinkListener(listener);
  }
Esempio n. 5
0
  public HTMLExplorerViewer(Composite parent, int type) {
    super(parent);

    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.marginHeight = 0;
    gridLayout.horizontalSpacing = 0;
    gridLayout.verticalSpacing = 0;
    gridLayout.marginWidth = 0;
    setLayout(gridLayout);

    ApplicationFactory factory = new ApplicationFactory(this, "HTMLExplorer", "HTMLExplorer");
    suggestTip = factory.getLabel("suggest.tip");

    SashForm mainSash = new SashForm(this, SWT.VERTICAL);
    mainSash.setBackground(getBackground());
    GridData gridData = new GridData(GridData.FILL_BOTH);
    mainSash.setLayoutData(gridData);

    SashForm sash0 = new SashForm(mainSash, SWT.HORIZONTAL);
    sash0.setBackground(getBackground());
    sash0.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.VERTICAL_ALIGN_BEGINNING));

    Composite browserComposite = new Composite(sash0, SWT.NONE);
    browserComposite.setBackground(getBackground());
    gridLayout = new GridLayout(1, false);
    gridLayout.marginHeight = 0;
    gridLayout.horizontalSpacing = 0;
    gridLayout.verticalSpacing = 0;
    gridLayout.marginWidth = 0;
    browserComposite.setLayout(gridLayout);

    ToolbarResource.createInstance(getDisplay(), "HTMLExplorer", HTMLExplorer.class);
    //    toolbar = new HTMLExplorerToolbar(factory, browserComposite, this);
    //    gridData = new GridData(GridData.FILL_HORIZONTAL);
    //    toolbar.setLayoutData(gridData);
    //    toolbar.setBackground(getBackground());

    browser = ApplicationFactory.createBrowser(browserComposite, PageMenu.class);
    if (ApplicationFactory.isMozillaBrowser()) {
      browser.addProgressListener(
          new ProgressAdapter() {
            @SuppressWarnings("unused")
            public void completed(ProgressEvent event) {
              nsIWebBrowser webBrowser = (nsIWebBrowser) browser.getWebBrowser();
              if (webBrowser == null) return;
              nsIDOMWindow domWindow = webBrowser.getContentDOMWindow();
              if (domWindow == null) return;
              nsIDOMEventTarget target =
                  (nsIDOMEventTarget)
                      domWindow.queryInterface(nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID);
              nsIDOMEventListener listener =
                  new nsIDOMEventListener() {
                    public nsISupports queryInterface(String uuid) {
                      if (uuid.equals(nsIDOMEventListener.NS_IDOMEVENTLISTENER_IID)
                          || uuid.equals(nsIDOMEventListener.NS_ISUPPORTS_IID)) {
                        return this;
                      }
                      return null;
                    }

                    public void handleEvent(nsIDOMEvent devent) {
                      nsIDOMElement element =
                          (nsIDOMElement)
                              devent.getTarget().queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
                      String text = element.getFirstChild().getNodeValue();
                      if (text == null || text.trim().isEmpty() || "null".equalsIgnoreCase(text))
                        return;
                      search(text.trim());
                    }
                  };
              target.addEventListener("click", listener, false);
            }
          });
    }

    gridData = new GridData(GridData.FILL_BOTH);
    browser.setLayoutData(gridData);
    browser.setBackground(getBackground());
    browser.addProgressListener(
        new ProgressAdapter() {
          public void changed(ProgressEvent event) {
            if (event.total == 0) return;
            int ratio = event.current * 100 / event.total;
            showInformation("Loading " + String.valueOf(ratio) + "%");
            String url = browser.getUrl();
            if (url != null && url.length() > 2 && !url.startsWith("about")) {
              currentURL = url;
            }
          }

          @SuppressWarnings("unused")
          public void completed(ProgressEvent event) {
            showInformation(suggestTip);
          }
        });

    browser.addStatusTextListener(
        new StatusTextListener() {
          @SuppressWarnings("unused")
          public void changed(StatusTextEvent event) {
            String url = browser.getUrl();
            if (url == null) return;
            if (url.indexOf('/') < 0) return;
            showInformation("Waiting for " + browser.getUrl());
            //        toolbar.setText(browser.getUrl());
          }
        });

    factory.setComposite(browserComposite);
    tree = new Tree(sash0, SWT.MULTI | SWT.BORDER);
    tree.addSelectionListener(
        new SelectionAdapter() {
          @SuppressWarnings("unused")
          public void widgetSelected(SelectionEvent evt) {
            String path = selectTree();
            if (path != null) box.setSuggestPath(path);
          }
        });
    tree.addMouseListener(
        new MouseAdapter() {
          public void mouseDown(MouseEvent e) {
            if (e.button == 2) addItems();
          }
        });
    tree.setToolTipText(suggestTip);

    Menu treeMenu = new Menu(getShell(), SWT.POP_UP);
    tree.setMenu(treeMenu);

    factory.createStyleMenuItem(
        treeMenu,
        "itemAdd",
        "+.gif",
        new SelectionAdapter() {
          @SuppressWarnings("unused")
          public void widgetSelected(SelectionEvent evt) {
            try {
              traverseTree(TreeHandler.SELECT, addItems());
            } catch (Exception e) {
              ClientLog.getInstance().setMessage(tree.getShell(), e);
            }
          }
        });

    factory.createStyleMenuItem(
        treeMenu,
        "itemRemove",
        "-.gif",
        new SelectionAdapter() {
          @SuppressWarnings("unused")
          public void widgetSelected(SelectionEvent evt) {
            try {
              removeItem();
            } catch (Exception e) {
              ClientLog.getInstance().setMessage(tree.getShell(), e);
            }
          }
        });

    factory.createStyleMenuItem(treeMenu, SWT.SEPARATOR);

    factory.createStyleMenuItem(
        treeMenu,
        "itemExpand",
        new SelectionAdapter() {
          @SuppressWarnings("unused")
          public void widgetSelected(SelectionEvent evt) {
            expand(true);
          }
        });

    factory.createStyleMenuItem(
        treeMenu,
        "itemCollapse",
        new SelectionAdapter() {
          @SuppressWarnings("unused")
          public void widgetSelected(SelectionEvent evt) {
            expand(false);
          }
        });

    factory.createStyleMenuItem(treeMenu, SWT.SEPARATOR);

    factory.createStyleMenuItem(
        treeMenu,
        "itemExpandDataNode",
        new SelectionAdapter() {
          @SuppressWarnings("unused")
          public void widgetSelected(SelectionEvent evt) {
            expandDataNode();
          }
        });

    factory.createStyleMenuItem(
        treeMenu,
        "itemCollapseTree",
        new SelectionAdapter() {
          @SuppressWarnings("unused")
          public void widgetSelected(SelectionEvent evt) {
            TreeItem[] items = tree.getItems();
            if (items == null) return;
            for (TreeItem item : items) {
              expand(item, false);
            }
          }
        });

    factory.createStyleMenuItem(treeMenu, SWT.SEPARATOR);

    factory.createStyleMenuItem(
        treeMenu,
        "itemView",
        "view.gif",
        new SelectionAdapter() {
          @SuppressWarnings("unused")
          public void widgetSelected(SelectionEvent evt) {
            viewItem();
          }
        });

    sash0.setWeights(new int[] {500, 300});
    handler = new TreeHandler();
    box = new PathBox(mainSash, factory);
    box.setLayoutData(gridData);
    //    String [] paths = {
    //
    // "BODY[0].TABLE[0].TBODY[0].TR[0].TD[0].TABLE[5].TBODY[0].TR[0].TD[0].TABLE[0].TBODY[0].TR[0].TD[2].TABLE[2].TBODY[0].TR[0].TD[0].TABLE[1].TBODY[0].TR[0].TD[2]",
    //
    // "BODY[0].TABLE[0].TBODY[0].TR[0].TD[0].TABLE[5].TBODY[0].TR[0].TD[0].TABLE[0].TBODY[0].TR[0].TD[2].TABLE[2].TBODY[0].TR[0].TD[0].TABLE[2].TBODY[0].TR[1]",
    //        "BODY[0].DIV[0].DIV[4].DIV[0].DIV[0]",
    //
    // "BODY[0].DIV[0].DIV[0].DIV[2].DIV[0].DIV[0].DIV[0].TABLE[0].TBODY[0].TR[1].TD[0].TABLE[0].TBODY[0].TR[1].TD[0].TABLE[0].TBODY[0].TR[0].TD[1].CONTENT[2]]"
    //    };
    //    box.setItems(paths);
    box.addSelectionListener(
        new SelectionAdapter() {
          @SuppressWarnings("unused")
          public void widgetSelected(SelectionEvent e) {
            lblStatus.setText("");
            String path = box.getSelectedPath();
            if (path == null) return;
            try {
              traverseTree(TreeHandler.SELECT, new String[] {path});
            } catch (Exception exp) {
              ClientLog.getInstance().setMessage(tree.getShell(), exp);
            }
            if (isErrorPath(path)) showErrorPath(path);
          }
        });
    box.addSelectionListener(
        new SelectionAdapter() {
          @SuppressWarnings("unused")
          public void widgetSelected(SelectionEvent e) {
            //        butDown.setVisible(true);
            //        butUp.setVisible(true);
            highlightErrorPath(box.getSelectedPath());
          }
        });
    box.addItemChangePath(
        new PathBox.ChangePath() {
          @Override
          public void change(PathEvent event) {
            traverseByPath(event.getPath());
            //        NodePathParser pathParser = new NodePathParser();
            //        NodePath nodePath = null;
            //        try {
            //          nodePath = pathParser.toPath(path);
            //        } catch (Exception exp) {
            //          return;
            //        }
            //        handler.traverseTree(HTMLExplorerViewer.this, tree, nodePath, path);
          }
        });
    box.addItemRemovePath(
        new RemovePath() {
          public void remove(PathEvent event) {
            try {
              traverseTree(TreeHandler.REMOVE, new String[] {event.getPath()});
            } catch (Exception e) {
              ClientLog.getInstance().setMessage(getShell(), e);
            }
          }
        });
    box.addItemCurrentPath(
        new PathBox.CurrentPath() {
          @Override
          public void change(PathBox.PathEvent event) {
            if (document == null) return;
            String path = event.getPath();
            String[] attrs = getAttrs(path);
            box.showAttrItemPopup(attrs);
          }
        });
    box.addSuggestCurrentPath(
        new PathBox.CurrentPath() {
          @Override
          public void change(PathBox.PathEvent event) {
            if (document == null) return;
            String path = event.getPath();
            String[] attrs = getAttrs(path);
            box.getSuggestWidget().showAttrSuggestion(attrs);
          }
        });

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

    if (type == HTMLExplorer.CONTENT) createButtonComponent(factory);
  }
Esempio n. 6
0
  protected void createButtonComponent(ApplicationFactory factory) {
    Composite buttonComposite = new Composite(this, SWT.NONE);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    buttonComposite.setLayoutData(gridData);
    factory.setComposite(buttonComposite);

    GridLayout gridLayout = new GridLayout(3, false);
    gridLayout.marginHeight = 0;
    gridLayout.horizontalSpacing = 15;
    gridLayout.verticalSpacing = 0;
    gridLayout.marginWidth = 10;
    buttonComposite.setLayout(gridLayout);

    Composite removeComposite = new Composite(buttonComposite, SWT.NONE);
    buttonComposite.setBackground(getBackground());
    removeComposite.setLayout(new GridLayout(2, false));
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    removeComposite.setLayoutData(gridData);

    factory.setComposite(removeComposite);

    /* butRemoveAll = factory.createButton(SWT.PUSH);
    butRemoveAll.setText(factory.getResources().getLabel("menuRemoveAll"));
    butRemoveAll.addSelectionListener(new SelectionAdapter(){
      @SuppressWarnings("unused")
      public void widgetSelected(SelectionEvent evt) {
        MessageBox msg = new MessageBox (getShell(), SWT.APPLICATION_MODAL | SWT.YES | SWT.NO);
        ClientRM clientRM = new ClientRM("HTMLExplorer");
        msg.setMessage(clientRM.getLabel("remove.all.message"));
        if(msg.open() != SWT.YES) return ;
        box.removeAll();
      }
    });
    //    butRemoveAll.setVisible(false);
    butRemoveAll.setFont(UIDATA.FONT_9);

    butUp = factory.createButton(SWT.PUSH);
    butUp.setText(factory.getResources().getLabel("menuUp"));
    butUp.addSelectionListener(new SelectionAdapter(){
      @SuppressWarnings("unused")
      public void widgetSelected(SelectionEvent evt) {
        box.up();
      }
    });
    butUp.setVisible(false);
    butUp.setFont(UIDATA.FONT_9);

    butDown = factory.createButton(SWT.PUSH);
    butDown.setText(factory.getResources().getLabel("menuDown"));
    butDown.addSelectionListener(new SelectionAdapter(){
      @SuppressWarnings("unused")
      public void widgetSelected(SelectionEvent evt) {
        box.down();
      }
    });
    butDown.setVisible(false);
    butDown.setFont(UIDATA.FONT_9);*/

    lblStatus = factory.createLabel(SWT.NONE);
    lblStatus.setBackground(getBackground());
    gridData = new GridData();
    gridData.minimumWidth = 180;
    lblStatus.setLayoutData(gridData);
    lblStatus.setFont(UIDATA.FONT_10B);
    lblStatus.setForeground(getDisplay().getSystemColor(SWT.COLOR_RED));

    butRemovePath = factory.createButton(SWT.PUSH);
    butRemovePath.setText(factory.getResources().getLabel("remove.path.yes"));
    butRemovePath.addSelectionListener(
        new SelectionAdapter() {
          @SuppressWarnings("unused")
          public void widgetSelected(SelectionEvent evt) {
            if (errorPath != null) {
              box.removePath(errorPath);
              clearInformation();
            }
            showErrorPath(null);
          }
        });
    butRemovePath.setVisible(false);
    butRemovePath.setFont(UIDATA.FONT_9);

    //    Label lblSuggest = factory.createLabel(SWT.NONE);
    //    lblSuggest.setBackground(getBackground());
    //    gridData = new GridData(GridData.FILL_HORIZONTAL);
    //    //    gridData.widthHint = 305;
    //    lblSuggest.setLayoutData(gridData);
    //    lblSuggest.setFont(UIDATA.FONT_10B);
    ////    lblSuggest.setForeground(getDisplay().getSystemColor(SWT.COLOR_BLUE));
    //    lblSuggest.setText(factory.getLabel("suggest.tip"));

    factory.setComposite(buttonComposite);

    String butTip = factory.getLabel("butOk");
    final ToolbarResource resources = ToolbarResource.getInstance();
    butOk =
        resources.createIcon(
            factory.getComposite(),
            resources.getImageGo(),
            butTip,
            new HyperlinkAdapter() {
              @SuppressWarnings("unused")
              public void linkActivated(HyperlinkEvent e) {
                butOk.setImage(resources.getImageGo());
              }

              @SuppressWarnings("unused")
              public void linkExited(HyperlinkEvent e) {
                butOk.setImage(resources.getImageGo());
              }

              @SuppressWarnings("unused")
              public void linkEntered(HyperlinkEvent e) {
                butOk.setImage(resources.getImageGo());
              }
            });
    butOk.addMouseListener(
        new MouseAdapter() {
          @SuppressWarnings("unused")
          public void mouseUp(MouseEvent e) {
            invisibleComponent();
            clickOk();
          }

          @SuppressWarnings("unused")
          public void mouseDown(MouseEvent e) {
            butOk.setImage(resources.getImageGo1());
            butOk.redraw();
          }
        });

    butTip = factory.getLabel("butCancel");
    butCancel =
        resources.createIcon(
            factory.getComposite(),
            resources.getImageCancel(),
            butTip,
            new HyperlinkAdapter() {
              @SuppressWarnings("unused")
              public void linkActivated(HyperlinkEvent e) {
                butCancel.setImage(resources.getImageCancel());
              }

              @SuppressWarnings("unused")
              public void linkExited(HyperlinkEvent e) {
                butCancel.setImage(resources.getImageCancel());
              }

              @SuppressWarnings("unused")
              public void linkEntered(HyperlinkEvent e) {
                butCancel.setImage(resources.getImageCancel());
              }
            });
    butCancel.addMouseListener(
        new MouseAdapter() {
          @SuppressWarnings("unused")
          public void mouseUp(MouseEvent e) {
            invisibleComponent();
            clickCancel();
          }

          @SuppressWarnings("unused")
          public void mouseDown(MouseEvent e) {
            butCancel.setImage(resources.getImageCancel1());
            butCancel.redraw();
          }
        });

    //    factory.setComposite(bottom);
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);

    /*  String url = "";
    try {
      Preferences prefs = Preferences.userNodeForPackage(HTMLExplorer.class);
      url  = prefs.get("url.address", "");
    } catch (Exception e) {
      url = "";
    }*/
    //    toolbar.setText(url);

    //    treeAddButton = new TreeAddButton(this);
    //    viewFunctions();
  }