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));
 }
Exemplo n.º 2
0
 private void shellWidgetDisposed(DisposeEvent evt) {
   try {
     // Save app settings to file
     appSettings.store(new FileOutputStream("appsettings.ini"), "");
   } catch (FileNotFoundException e) {
   } catch (IOException e) {
   }
 }
Exemplo n.º 3
0
  // Load application settings from .ini file
  private void setPreferences() {
    try {
      appSettings.load(new FileInputStream("appsettings.ini"));
    } catch (FileNotFoundException e) {
    } catch (IOException e) {
    }

    // By default, center window
    int width = Integer.parseInt(appSettings.getProperty("width", "640"));
    int height = Integer.parseInt(appSettings.getProperty("height", "480"));
    Rectangle screenBounds = getDisplay().getBounds();
    int defaultTop = (screenBounds.height - height) / 2;
    int defaultLeft = (screenBounds.width - width) / 2;
    int top = Integer.parseInt(appSettings.getProperty("top", String.valueOf(defaultTop)));
    int left = Integer.parseInt(appSettings.getProperty("left", String.valueOf(defaultLeft)));
    getShell().setSize(width, height);
    getShell().setLocation(left, top);
    saveShellBounds();
  }
Exemplo n.º 4
0
 private void exitMenuItemWidgetSelected(SelectionEvent evt) {
   try {
     // Save app settings to file
     appSettings.store(new FileOutputStream("appsettings.ini"), "");
   } catch (FileNotFoundException e) {
   } catch (IOException e) {
   }
   getShell().dispose();
   System.exit(1);
 }
    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);
    }
  private String[] getAvailableProperties(String value) {
    if (value == null || value.length() == 0) {
      return new String[0];
    }
    JSFPromptingProvider provider = new JSFPromptingProvider();

    XModel xModel = getXModel();
    if (xModel == null) {
      // lets create fake model, which can build properties for the value.
      IFile file = (IFile) properties.get("file"); // $NON-NLS-1$
      if (file != null) {
        XModelObject f = EclipseResourceUtil.createObjectForResource(file);
        if (f != null) {
          xModel = f.getModel();
        }
      }
    }
    if (xModel == null) {
      return new String[0];
    }

    return (String[]) provider.buildBeanProperties(xModel, value, null).toArray(new String[0]);
  }
 private XModel getXModel() {
   IFile file = (IFile) properties.get("file"); // $NON-NLS-1$
   return file == null ? null : getXModel(file);
 }