Exemplo n.º 1
0
 @Override
 protected void setSelectionToWidget(List in, boolean reveal) {
   if (reveal) {
     super.setSelectionToWidget(in, reveal);
   } else {
     if (in == null || in.size() == 0) { // clear selection
       list.deselectAll();
     } else {
       int n = in.size();
       int[] ixs = new int[n];
       int count = 0;
       for (int i = 0; i < n; ++i) {
         Object el = in.get(i);
         int ix = getElementIndex(el);
         if (ix >= 0) {
           ixs[count++] = ix;
         }
       }
       if (count < n) {
         System.arraycopy(ixs, 0, ixs = new int[count], 0, count);
       }
       list.deselectAll();
       list.select(ixs);
     }
   }
 }
Exemplo n.º 2
0
  @Override
  public void setPackageProductType(ProductType packageProductType) {
    this.packageProductType = packageProductType;
    this.packageProductTypeItem = null;
    productTypeItemList.clear();
    productTypeGUIList.removeAll();

    if (packageProductType != null) {
      String languageID = NLLocale.getDefault().getLanguage();

      if (packageProductType.getInnerPriceConfig() != null) {
        productTypeItemList.add(new Item(false, true, packageProductType));
        productTypeGUIList.add(
            packageProductType.getName().getText(languageID)
                + Messages.getString(
                    "org.nightlabs.jfire.trade.admin.ui.gridpriceconfig.ProductTypeSelectorListImpl.packageProductType_base")); //$NON-NLS-1$
      }

      //			EventInnerProductInfo assemblyInnerProductInfo =
      // assemblyPackageProductInfo.getEventInnerProductInfo();
      //			if (!(assemblyInnerProductInfo.getPriceConfig() instanceof FormulaPriceConfig))
      //				throw new IllegalArgumentException("The PriceConfig of assemblyInnerProductInfo is not
      // an instance of FormulaPriceConfig!");
      //
      //			productTypeItemList.add(assemblyInnerProductInfo);
      //			productTypeGUIList.add(assemblyInnerProductInfo.getPrimaryKey()); // TO DO i18n

      for (NestedProductTypeLocal nestedProductTypeLocal :
          packageProductType.getProductTypeLocal().getNestedProductTypeLocals()) {
        ProductType productType =
            nestedProductTypeLocal.getInnerProductTypeLocal().getProductType();
        //				if (assemblyInnerProductInfo == productInfo)
        //					continue;

        productTypeItemList.add(new Item(false, false, productType));
        productTypeGUIList.add(
            productType.getName().getText(languageID)
                + " ["
                + nestedProductTypeLocal.getQuantity()
                + "]"); //$NON-NLS-1$ //$NON-NLS-2$
      }

      if (packageProductType.getPackagePriceConfig() != null) {
        packageProductTypeItem = new Item(true, false, packageProductType);
        productTypeItemList.add(packageProductTypeItem);
        productTypeGUIList.add(
            packageProductType.getName().getText(languageID)
                + Messages.getString(
                    "org.nightlabs.jfire.trade.admin.ui.gridpriceconfig.ProductTypeSelectorListImpl.packageProductType_total")); //$NON-NLS-1$
      }

      productTypeGUIList.select(0);
    } // if (assemblyPackageProductInfo != null) {

    fireSelectionChangedEvent();
  }
 private void selectionChanged(int newSelection) {
   // make StructuredChangedEvent and notify StructuredChangeListener
   StructuredChange change = new StructuredChange(elements);
   StructuredChangedEvent event = new StructuredChangedEvent(listContentProvider, change);
   structuredChangeListener.structureChanged(event);
   if (newSelection >= 0 && newSelection < list.getItemCount()) {
     list.select(newSelection);
   }
   updateSelectionDependentActions();
 }
 private void guess() {
   // Guess the target for all the sources...
   for (int i = 0; i < sourceList.length; i++) {
     int idx = Const.indexOfString(sourceList[i], wSource.getItems());
     if (idx >= 0) {
       wSource.select(idx);
       if (findTarget()) {
         add();
       }
     }
   }
 }
  /** It is called when the selection focus is changed */
  private void changeSelection(int idx) {
    if (0 <= idx && idx < parserList.size()) {
      compilerList.select(idx);
      boolean removable = ((ErrorParser) parserList.get(idx)).isEditable();
      removeButton.setEnabled(removable);

      updateTextField(idx);
    } else {
      // maybe never executed
      removeButton.setEnabled(false);
      updateTextField(-1);
    }
  }
Exemplo n.º 6
0
 /**
  * Selects the item at the given zero-relative index in the receiver's list. If the item at the
  * index was already selected, it remains selected. Indices that are out of range are ignored.
  *
  * @param index the index of the item to select
  * @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 select(int index) {
   checkWidget();
   if (index == -1) {
     list.deselectAll();
     text.setText(""); // $NON-NLS-1$
     return;
   }
   if (0 <= index && index < list.getItemCount()) {
     if (index != getSelectionIndex()) {
       text.setText(list.getItem(index));
       text.selectAll();
       list.select(index);
       list.showSelection();
     }
   }
 }
Exemplo n.º 7
0
  /**
   * set a model to apply content to user interface.
   *
   * @param p a dynabeanfunction
   */
  public void setModel(Object p) {

    dynaBeanFunction = ((DynaBeanFunction) ((TreeObject) p).getUserObject());
    treeObject = (TreeObject) p;

    textName.setText(dynaBeanFunction.getName() == null ? "" : dynaBeanFunction.getName());
    textProperty.setText(dynaBeanFunction == null ? "" : dynaBeanFunction.getPropertyName());

    listMethods.removeAll();
    listParameter.removeAll();

    textClass.setData(dynaBeanFunction.getMethod().getDeclaringClass());
    textClass.setText(dynaBeanFunction.getMethod().getDeclaringClass().toString());
    setList(dynaBeanFunction.getMethod().getDeclaringClass());
    String[] items = listMethods.getItems();

    for (int i = 0; i < items.length; i++) {
      if (items[i].equals(dynaBeanFunction.getMethod().toString())) {
        listMethods.select(i);
        displayMethodDetails(dynaBeanFunction.getMethod());
        break;
      }
    }
  }
Exemplo n.º 8
0
  public Object open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();

    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX);
    props.setLook(shell);

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

    shell.setLayout(formLayout);
    shell.setText(
        BaseMessages.getString(
            PKG, "EnterPreviewRowsDialog.Dialog.PreviewStep.Title")); // Select the preview step:
    shell.setImage(GUIResource.getInstance().getImageLogoSmall());

    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;

    // Filename line
    wlStepList = new Label(shell, SWT.NONE);
    wlStepList.setText(
        BaseMessages.getString(
            PKG, "EnterPreviewRowsDialog.Dialog.PreviewStep.Message")); // Step name :
    props.setLook(wlStepList);
    fdlStepList = new FormData();
    fdlStepList.left = new FormAttachment(0, 0);
    fdlStepList.top = new FormAttachment(0, margin);
    wlStepList.setLayoutData(fdlStepList);
    wStepList =
        new List(
            shell,
            SWT.SINGLE | SWT.LEFT | SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL);
    for (int i = 0; i < stepNames.size(); i++) {
      wStepList.add((String) stepNames.get(i));
    }
    wStepList.select(0);
    props.setLook(wStepList);
    fdStepList = new FormData();
    fdStepList.left = new FormAttachment(middle, 0);
    fdStepList.top = new FormAttachment(0, margin);
    fdStepList.bottom = new FormAttachment(100, -60);
    fdStepList.right = new FormAttachment(100, 0);
    wStepList.setLayoutData(fdStepList);
    wStepList.addSelectionListener(
        new SelectionAdapter() {
          public void widgetDefaultSelected(SelectionEvent arg0) {
            show();
          }
        });

    wShow = new Button(shell, SWT.PUSH);
    wShow.setText(BaseMessages.getString(PKG, "System.Button.Show"));

    wClose = new Button(shell, SWT.PUSH);
    wClose.setText(BaseMessages.getString(PKG, "System.Button.Close"));

    BaseStepDialog.positionBottomButtons(shell, new Button[] {wShow, wClose}, margin, null);
    // Add listeners
    lsShow =
        new Listener() {
          public void handleEvent(Event e) {
            show();
          }
        };
    lsClose =
        new Listener() {
          public void handleEvent(Event e) {
            close();
          }
        };

    wShow.addListener(SWT.Selection, lsShow);
    wClose.addListener(SWT.Selection, lsClose);

    // 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);

    // Immediately show the only preview entry
    if (stepNames.size() == 1) {
      wStepList.select(0);
      show();
    }

    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    return stepname;
  }
  public String open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();

    shell =
        new Shell(
            parent,
            SWT.DIALOG_TRIM
                | (modal ? SWT.APPLICATION_MODAL | SWT.SHEET : SWT.NONE)
                | SWT.RESIZE
                | SWT.MIN
                | SWT.MAX);
    props.setLook(shell);

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

    shell.setLayout(formLayout);
    shell.setText(shellText);
    shell.setImage(GUIResource.getInstance().getImageSpoon());

    int margin = Const.MARGIN;

    if (quickSearch) {
      ToolBar treeTb = new ToolBar(shell, SWT.HORIZONTAL | SWT.FLAT);
      props.setLook(treeTb);

      ToolItem wtfilter = new ToolItem(treeTb, SWT.SEPARATOR);
      Label wlfilter = new Label(treeTb, SWT.SEARCH);
      props.setLook(wlfilter);
      wlfilter.setText(BaseMessages.getString(PKG, "EnterSelectionDialog.FilterString.Label"));
      wtfilter.setControl(wlfilter);
      if (Const.isOSX()) {
        wtfilter.setWidth(100);
      } else {
        wtfilter.setWidth(70);
      }

      wfilter = new ToolItem(treeTb, SWT.SEPARATOR);
      searchText = new Text(treeTb, SWT.SEARCH | SWT.CANCEL);
      props.setLook(searchText);
      searchText.setToolTipText(
          BaseMessages.getString(PKG, "EnterSelectionDialog.FilterString.ToolTip"));
      wfilter.setControl(searchText);
      wfilter.setWidth(120);

      wbRegex = new ToolItem(treeTb, SWT.CHECK);
      wbRegex.setImage(GUIResource.getInstance().getImageRegexSmall());
      wbRegex.setToolTipText(BaseMessages.getString(PKG, "EnterSelectionDialog.useRegEx.Tooltip"));

      goSearch = new ToolItem(treeTb, SWT.PUSH);
      goSearch.setImage(GUIResource.getInstance().getImageSearchSmall());
      goSearch.setToolTipText(BaseMessages.getString(PKG, "EnterSelectionDialog.refresh.Label"));

      goSearch.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(SelectionEvent event) {
              updateFilter();
            }
          });

      if (this.databasesInterface != null) {
        addConnection = new ToolItem(treeTb, SWT.PUSH);
        addConnection.setImage(GUIResource.getInstance().getImageAdd());
        addConnection.setToolTipText(BaseMessages.getString(PKG, "Add.Datasource.Label"));

        addConnection.addSelectionListener(
            new SelectionAdapter() {
              public void widgetSelected(SelectionEvent event) {
                addDataSource();
              }
            });
      }

      FormData fd = new FormData();
      fd.right = new FormAttachment(100, -margin);
      fd.top = new FormAttachment(0, margin);
      treeTb.setLayoutData(fd);

      searchText.addSelectionListener(
          new SelectionAdapter() {
            public void widgetDefaultSelected(SelectionEvent e) {
              updateFilter();
            }
          });

      // From step line
      wlSelection = new Label(shell, SWT.NONE);
      wlSelection.setText(lineText);
      props.setLook(wlSelection);
      fdlSelection = new FormData();
      fdlSelection.left = new FormAttachment(0, 0);
      fdlSelection.top = new FormAttachment(treeTb, margin);
      wlSelection.setLayoutData(fdlSelection);
    } else {
      // From step line
      wlSelection = new Label(shell, SWT.NONE);
      wlSelection.setText(lineText);
      props.setLook(wlSelection);
      fdlSelection = new FormData();
      fdlSelection.left = new FormAttachment(0, 0);
      wlSelection.setLayoutData(fdlSelection);
    }

    int options = SWT.LEFT | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL;
    if (multi) {
      options |= SWT.MULTI;
    } else {
      options |= SWT.SINGLE;
    }

    wSelection = new List(shell, options);
    for (int i = 0; i < choices.length; i++) {
      wSelection.add(choices[i]);
    }
    if (selectedNrs != null) {
      wSelection.select(selectedNrs);
      wSelection.showSelection();
    }
    if (fixed) {
      props.setLook(wSelection, Props.WIDGET_STYLE_FIXED);
    } else {
      props.setLook(wSelection);
    }

    // Some buttons
    wOK = new Button(shell, SWT.PUSH);
    if (viewOnly) {
      wOK.setText(BaseMessages.getString(PKG, "System.Button.Close"));
    } else {
      wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    }
    lsOK =
        new Listener() {
          public void handleEvent(Event e) {
            ok();
          }
        };
    wOK.addListener(SWT.Selection, lsOK);

    Button[] buttons = new Button[] {wOK};

    if (!viewOnly) {
      wCancel = new Button(shell, SWT.PUSH);
      wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
      lsCancel =
          new Listener() {
            public void handleEvent(Event e) {
              cancel();
            }
          };
      wCancel.addListener(SWT.Selection, lsCancel);

      buttons = new Button[] {wOK, wCancel};
    }

    BaseStepDialog.positionBottomButtons(shell, buttons, margin, null);

    fdSelection = new FormData();
    fdSelection.left = new FormAttachment(0, 0);
    fdSelection.right = new FormAttachment(100, 0);
    fdSelection.top = new FormAttachment(wlSelection, margin);
    fdSelection.bottom = new FormAttachment(wOK, -margin * 3);
    wSelection.setLayoutData(fdSelection);

    // Add listeners

    lsDef =
        new SelectionAdapter() {
          public void widgetDefaultSelected(SelectionEvent e) {
            ok();
          }
        };
    wSelection.addSelectionListener(lsDef);
    wSelection.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            if (e.character == SWT.CR) {
              ok();
            }
          }
        });
    // Detect [X] or ALT-F4 or something that kills this window...
    shell.addShellListener(
        new ShellAdapter() {
          public void shellClosed(ShellEvent e) {
            cancel();
          }
        });

    getData();

    BaseStepDialog.setSize(shell);

    wOK.setFocus();

    shell.open();

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