protected void validate() {
    // TODO Validation
    if (folder.getSelectionIndex() == 0) {
      name = nameText.getText();
      userName = userNameText.getText();
      password = passwordText.getText();
      if (hostText.getText().equals(_BLANK_)) {
        showError(Messages.DefaultConnectionWizardPage_Blank_Invalid);
        return;
      }
      try {
        InetAddress.getByName(hostText.getText());
      } catch (UnknownHostException e) {
        showError(e.getMessage());
        return;
      }
      String host = hostText.getText();
      if (portText.getText().equals(_BLANK_)) {
        showError(Messages.DefaultConnectionWizardPage_Blank_Invalid);
        return;
      }
      int port;
      try {
        port = Integer.parseInt(portText.getText());
        if (port < 1 || port > 0xffff) {
          throw new NumberFormatException();
        }
      } catch (NumberFormatException e) {
        showError(e.getMessage());
        return;
      }
      url = SIMPLE_PREFIX + host + ":" + port + SIMPLE_SUFFIX; // $NON-NLS-1$
    } else if (folder.getSelectionIndex() == 1) {
      name = advancedNameText.getText();
      userName = advancedUserNameText.getText();
      password = advancedPasswordText.getText();

      if (urlText.getText().equals(_BLANK_)) {
        showError(Messages.DefaultConnectionWizardPage_Blank_Invalid);
        return;
      }
      url = urlText.getText();
    }

    // now validate name
    if (name == null || nameTaken(name)) {
      showError(Messages.DefaultConnectionWizardPage_Name_In_Use);
      return;
    }

    try {
      getConnection();
    } catch (CoreException ce) {
      showError(ce.getMessage());
      return;
    }

    clearMessage();
  }
 /**
  * Sets the control that is used to fill the client area of the tab folder when the user selects
  * the tab item.
  *
  * <p>
  *
  * @param control the new control (or null)
  * @exception IllegalArgumentException
  *     <ul>
  *       <li>ERROR_INVALID_ARGUMENT - if the control has been disposed
  *       <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree
  *     </ul>
  *
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public void setControl(Control control) {
   checkWidget();
   if (control != null) {
     if (control.isDisposed()) {
       error(SWT.ERROR_INVALID_ARGUMENT);
     }
     if (control.parent != parent) {
       error(SWT.ERROR_INVALID_PARENT);
     }
   }
   if (this.control != null && this.control.isDisposed()) {
     this.control = null;
   }
   Control oldControl = this.control;
   Control newControl = control;
   this.control = control;
   int index = parent.indexOf(this);
   if (index != parent.getSelectionIndex()) {
     if (newControl != null) {
       newControl.setVisible(false);
     }
   } else {
     if (newControl != null) {
       newControl.setBounds(parent.getClientArea());
       newControl.setVisible(true);
     }
     if (oldControl != null) {
       oldControl.setVisible(false);
     }
   }
 }
  private void saveDialogSettings() {
    IDialogSettings settings;
    IDialogSettings section;

    settings = SystemBrowserPlugin.getDefault().getDialogSettings();
    section = settings.addNewSection("PoolFilterDialog");

    section.put("target", targetCombo.getText());
    section.put("poolId", poolIdText.getText().trim());
    section.put("tab", tabFolder.getSelectionIndex());

    section.put("signalNumberFrom", signalNumberFromText.getText().trim());
    section.put("signalNumberTo", signalNumberToText.getText().trim());
    section.put("signalOwnerId", signalOwnerIdText.getText().trim());
    section.put("signalOwnerName", signalOwnerNameText.getText().trim());
    section.put("signalSenderId", signalSenderIdText.getText().trim());
    section.put("signalSenderName", signalSenderNameText.getText().trim());
    section.put("signalAddresseeId", signalAddresseeIdText.getText().trim());
    section.put("signalAddresseeName", signalAddresseeNameText.getText().trim());
    section.put("signalSizeFrom", signalSizeFromText.getText().trim());
    section.put("signalSizeTo", signalSizeToText.getText().trim());
    section.put("signalBufferSizeFrom", signalBufferSizeFromText.getText().trim());
    section.put("signalBufferSizeTo", signalBufferSizeToText.getText().trim());
    section.put("signalAddressFrom", signalAddressFromText.getText().trim());
    section.put("signalAddressTo", signalAddressToText.getText().trim());
    section.put("signalStatus", signalStatusCombo.getText());

    section.put("signalNumberExclude", signalNumberCheckbox.getSelection());
    section.put("signalOwnerIdExclude", signalOwnerIdCheckbox.getSelection());
    section.put("signalOwnerNameExclude", signalOwnerNameCheckbox.getSelection());
    section.put("signalSenderIdExclude", signalSenderIdCheckbox.getSelection());
    section.put("signalSenderNameExclude", signalSenderNameCheckbox.getSelection());
    section.put("signalAddresseeIdExclude", signalAddresseeIdCheckbox.getSelection());
    section.put("signalAddresseeNameExclude", signalAddresseeNameCheckbox.getSelection());
    section.put("signalSizeExclude", signalSizeCheckbox.getSelection());
    section.put("signalBufferSizeExclude", signalBufferSizeCheckbox.getSelection());
    section.put("signalAddressExclude", signalAddressCheckbox.getSelection());
    section.put("signalStatusExclude", signalStatusCheckbox.getSelection());

    section.put("stackOwnerId", stackOwnerIdText.getText().trim());
    section.put("stackOwnerName", stackOwnerNameText.getText().trim());
    section.put("stackSizeFrom", stackSizeFromText.getText().trim());
    section.put("stackSizeTo", stackSizeToText.getText().trim());
    section.put("stackBufferSizeFrom", stackBufferSizeFromText.getText().trim());
    section.put("stackBufferSizeTo", stackBufferSizeToText.getText().trim());
    section.put("stackAddressFrom", stackAddressFromText.getText().trim());
    section.put("stackAddressTo", stackAddressToText.getText().trim());
    section.put("stackUsedFrom", stackUsedFromText.getText().trim());
    section.put("stackUsedTo", stackUsedToText.getText().trim());
    section.put("stackUnusedFrom", stackUnusedFromText.getText().trim());
    section.put("stackUnusedTo", stackUnusedToText.getText().trim());

    section.put("stackOwnerIdExclude", stackOwnerIdCheckbox.getSelection());
    section.put("stackOwnerNameExclude", stackOwnerNameCheckbox.getSelection());
    section.put("stackSizeExclude", stackSizeCheckbox.getSelection());
    section.put("stackBufferSizeExclude", stackBufferSizeCheckbox.getSelection());
    section.put("stackAddressExclude", stackAddressCheckbox.getSelection());
    section.put("stackUsedExclude", stackUsedCheckbox.getSelection());
    section.put("stackUnusedExclude", stackUnusedCheckbox.getSelection());
  }
  private void turnToPage(SelectionEvent event) {
    final TabItem item = (TabItem) event.item;
    TabFolder folder = item.getParent();

    SearchPageDescriptor descriptor =
        (SearchPageDescriptor) item.getData("descriptor"); // $NON-NLS-1$

    if (item.getControl() == null) {
      item.setControl(createPageControl(folder, descriptor));
    }

    Control oldControl = folder.getItem(fCurrentIndex).getControl();
    Point oldSize = oldControl.getSize();
    Control newControl = item.getControl();
    Point newSize = newControl.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    resizeDialogIfNeeded(oldSize, newSize);

    ISearchPage oldPage = fCurrentPage;
    if (oldPage != null) {
      oldPage.setVisible(false);
    }

    fCurrentPage = descriptor.getPage();
    fDialogSettings.put(STORE_PREVIOUS_PAGE, descriptor.getId());
    fCurrentIndex = folder.getSelectionIndex();

    setPerformActionEnabled(fCurrentPage != null);
    if (fCurrentPage != null) {
      fCurrentPage.setVisible(true);
      Control pageControl = fCurrentPage.getControl();
      if (pageControl instanceof Composite) ((Composite) pageControl).layout(false, true);
    }
    fReplaceButton.setVisible(fCurrentPage instanceof IReplacePage);
    notifyPageChanged();
  }
Beispiel #5
0
 @Override
 public void handleMessage(int code, Object data) {
   switch (code) {
       // First re-check visibility of all tabs.
       // While tab deletion can be made on the fly,
       // tabs adding will be made by re-creation
       // of all elements, to preserve their order
     case ICPropertyTab.MANAGEDBUILDSTATE:
       if (folder == null) {
         if (itabs == null || itabs.size() == 0) return;
         ICPropertyTab t = itabs.get(0).tab;
         if (!t.canBeVisible()) t.handleTabEvent(ICPropertyTab.VISIBLE, null);
         return;
       }
       boolean willAdd = false;
       TabItem[] ts = folder.getItems();
       int x = folder.getSelectionIndex();
       String currHeader = (x == -1) ? null : ts[x].getText();
       for (int i = 0; i < itabs.size(); i++) {
         InternalTab itab = itabs.get(i);
         TabItem ti = null;
         for (TabItem element2 : ts) {
           if (element2.isDisposed()) continue;
           if (element2.getData() == itab.tab) {
             ti = element2;
             break;
           }
         }
         if (itab.tab.canBeVisible()) {
           if (ti == null) {
             willAdd = true;
             break;
           }
         } else {
           if (ti != null) ti.dispose();
         }
       }
       // in case of new tab added,
       // we have to dispose and re-create all tabs
       if (willAdd) {
         for (int j = 0; j < ts.length; j++)
           if (ts[j] != null && !ts[j].isDisposed()) ts[j].dispose();
         TabItem ti = null;
         for (int i = 0; i < itabs.size(); i++) {
           InternalTab itab = itabs.get(i);
           if (itab.tab.canBeVisible()) {
             TabItem currTI = itab.createOn(folder);
             if (currHeader != null && currHeader.equals(itab.text)) ti = currTI;
           }
         }
         if (ti != null) folder.setSelection(ti);
       }
       break;
   }
 }
 /**
  * Returns a rectangle describing the receiver's size and location relative to its parent.
  *
  * @return the receiver's bounding rectangle
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  *
  * @since 1.3
  */
 public Rectangle getBounds() {
   checkWidget();
   Rectangle result = new Rectangle(0, 0, 0, 0);
   int index = parent.indexOf(this);
   if (index != -1) {
     int selectionIndex = parent.getSelectionIndex();
     boolean selected = index == selectionIndex;
     Rectangle padding = parent.getItemPadding(selected);
     String text = getText();
     if (text != null) {
       Point extent = Graphics.stringExtent(parent.getFont(), text);
       result.width = extent.x;
       result.height = extent.y;
     }
     Image image = getImage();
     if (image != null) {
       Rectangle imageSize = image.getBounds();
       result.width += imageSize.width + IMAGE_TEXT_SPACING;
       result.height = Math.max(result.height, imageSize.height);
     }
     result.width += 2 * ITEM_BORDER + padding.width;
     result.height += ITEM_BORDER + padding.height;
     if (selected) {
       result.height += SELECTED_ITEM_BORDER;
     }
     if (selectionIndex != -1) {
       if (index + 1 == selectionIndex || index - 1 == selectionIndex) {
         result.width -= ITEM_BORDER;
       }
     }
     if (isBarTop()) {
       if (index != selectionIndex) {
         result.y += SELECTED_ITEM_BORDER;
       }
     } else {
       result.y = parent.getBounds().height - 2 * parent.getBorderWidth() - result.height;
       if (index != selectionIndex) {
         result.y -= SELECTED_ITEM_BORDER;
       }
     }
     if (index > 0) {
       TabItem leftItem = parent.getItem(index - 1);
       Rectangle leftItemBounds = leftItem.getBounds();
       result.x = leftItemBounds.x + leftItemBounds.width + TABS_SPACING;
       if (index == selectionIndex || index - 1 == selectionIndex) {
         result.x -= TABS_SPACING;
       }
     }
   }
   return result;
 }
  /**
   * Creates all the tabs in the detail pane to display the information for a given node.
   *
   * @param composite
   * @param node
   */
  public static void createTabs(Composite composite, INode node) {

    List<IDetailTab> tabs = getTabs(node);

    if (tabs == null || tabs.size() == 0) {
      // no detail found..

      Label label = new Label(composite, SWT.FILL);
      label.setText(
          Messages.getString("DatabaseDetailView.Tab.Unavailable") + " " + node.getLabelText());
      label.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));

      return;
    }

    // create tabs
    TabFolder tabFolder = new TabFolder(composite, SWT.NULL);

    // only init tabs when the tab becomes active
    tabFolder.addSelectionListener(
        new SelectionListener() {

          public void widgetDefaultSelected(SelectionEvent e) {

            // noop
          }

          public void widgetSelected(SelectionEvent e) {

            TabItem tabItem = (TabItem) e.item;
            IDetailTab tab = (IDetailTab) tabItem.getData();
            if (tab != null) {

              // create composite on tab and fill it..
              Composite detailComposite = new Composite(tabItem.getParent(), SWT.FILL);
              tabItem.setControl(detailComposite);
              detailComposite.setLayout(new FillLayout());
              tab.fillComposite(detailComposite);
              detailComposite.layout();

              // store tab name, so we can reselect when other node is
              // chosen
              DetailTabManager.setActiveTabName(tabItem.getText());
            }
          }
        });

    // add tabs to folder
    int tabIndex = 0;
    for (IDetailTab detailTab : tabs) {

      // create tab
      TabItem tabItem = new TabItem(tabFolder, SWT.NULL);
      tabItem.setText(detailTab.getLabelText());
      tabItem.setToolTipText(detailTab.getLabelToolTipText());

      // store tab so we can fill later
      tabItem.setData(detailTab);

      // reselect same tab as was previous selected
      if (tabItem.getText() != null && _activeTabName != null) {
        if (tabItem.getText().equals(_activeTabName)) {
          tabFolder.setSelection(tabIndex);
        }
      }

      tabIndex++;
    }

    // load data for active tab, default to first one if none is selected
    tabIndex = tabFolder.getSelectionIndex();
    if (tabIndex == -1) {
      tabIndex = 0;
    }

    TabItem tabItem = tabFolder.getItem(tabIndex);
    if (tabItem != null) {
      Composite detailComposite = new Composite(tabItem.getParent(), SWT.FILL);
      tabItem.setControl(detailComposite);
      detailComposite.setLayout(new FillLayout());
      IDetailTab tab = (IDetailTab) tabItem.getData();
      tab.fillComposite(detailComposite);
      detailComposite.layout();
    }

    tabFolder.layout();
  }