Exemplo n.º 1
0
 // Save window location in appSettings hash table
 private void saveShellBounds() {
   // Save window bounds in app settings
   Rectangle bounds = getShell().getBounds();
   appSettings.setProperty("top", String.valueOf(bounds.y));
   appSettings.setProperty("left", String.valueOf(bounds.x));
   appSettings.setProperty("width", String.valueOf(bounds.width));
   appSettings.setProperty("height", String.valueOf(bounds.height));
 }
    protected void add() {
      String[] ap = getAvailableProperties(data.getValue("value bean class")); // $NON-NLS-1$
      String[] sp = getSelectedProperties();
      Properties p = new Properties();
      Set<String> set1 = new HashSet<String>(), set2 = new TreeSet<String>();
      for (int i = 0; i < sp.length; i++) set1.add(sp[i]);
      for (int i = 0; i < ap.length; i++) if (!set1.contains(ap[i])) set2.add(ap[i]);
      String[][] vs = new String[set1.size() + set2.size()][2];
      int k = 0;
      for (String s : set1) {
        vs[k][0] = s;
        vs[k][1] = "no"; // "no" = selected //$NON-NLS-1$
        ++k;
      }
      for (String s : set2) {
        vs[k][0] = s;
        vs[k][1] = "yes"; // $NON-NLS-1$
        ++k;
      }

      p.put("data", vs); // $NON-NLS-1$
      SelectPropertiesWizard w = new SelectPropertiesWizard();
      p.setProperty("title", JsfUIMessages.DataTableWizardPage_BeanProperties); // $NON-NLS-1$
      w.setObject(p);
      int r = w.execute();
      if (r != 0) return;
      vs = (String[][]) p.get("data"); // $NON-NLS-1$
      List<String> list = new ArrayList<String>();
      for (int i = 0; i < vs.length; i++) {
        if (vs[i][1].equals("no")) { // $NON-NLS-1$
          list.add(vs[i][0]);
        }
      }
      sp = list.toArray(new String[0]);
      setSelectedProperties(sp);
    }