Exemplo n.º 1
0
  private void edit() {
    IStructuredSelection selection = (IStructuredSelection) propsTableViewer.getSelection();
    ConfigPropType prop = (ConfigPropType) selection.getFirstElement();

    String title = "Edit";
    AddPropertyDialog dialog =
        new AddPropertyDialog(
            propsTableViewer.getControl().getShell(),
            title,
            new String[] {prop.getName(), prop.getType(), prop.getValue()});

    if (dialog.open() == Window.CANCEL) {
      return;
    }

    String[] pair = dialog.getNameValuePair();
    String name = pair[0];
    /*
    if (!name.equals(originalName)) {
        if (!overwrite(name)){
            return;
        }
    }
    */
    prop.setName(name);
    prop.setType(pair[1]);
    prop.setValue(pair[2]);
    ((PropsContentProvider) propsTableViewer.getContentProvider()).update(prop);

    container.update();
  }
Exemplo n.º 2
0
  /** Allows the user to enter a user property */
  private void addProperty() {
    String title = "Add";
    AddPropertyDialog dialog =
        new AddPropertyDialog(
            propsTableViewer.getControl().getShell(), title, new String[] {"", "", ""});
    if (dialog.open() == Window.CANCEL) {
      return;
    }

    String[] pair = dialog.getNameValuePair();
    String name = pair[0];
    /*
    if (!overwrite(name)) {
        return;
    }
    */

    List<ConfigPropType> propList = aoDef.getAoConfigProps();

    ConfigPropType prop = new ConfigPropType();
    prop.setName(name);
    prop.setType(pair[1]);
    prop.setValue(pair[2]);
    ((PropsContentProvider) propsTableViewer.getContentProvider()).add(prop);
    propList.add(prop);
    container.update();
  }
Exemplo n.º 3
0
  private void remove(TableViewer viewer) {
    PropsContentProvider propContentProvider = (PropsContentProvider) viewer.getContentProvider();
    IStructuredSelection sel = (IStructuredSelection) viewer.getSelection();
    ConfigPropType prop = (ConfigPropType) sel.getFirstElement();
    aoDef.getAoConfigProps().remove(prop);
    propContentProvider.remove(sel);

    container.update();
  }
 public void setSelected(FModel fmodel) {
   if (selectedModel == fmodel) return;
   selectedModel = fmodel;
   if (selectedModel instanceof FConstantsModel) {
     currentEditor = constants;
     enableComponent(0);
     constants.setFModel(fmodel);
     dependency.setFModel(null);
   } else if (selectedModel instanceof FieldModel) {
     fmodel = ((FieldModel) fmodel).getDefaultDependency();
     dependency.setFModel(fmodel);
     dependency.getFieldEditor().setEnabled(true);
     constants.setFModel(null);
     if (currentEditor != dependency) {
       currentEditor = dependency;
       enableComponent(1);
     }
   } else if (selectedModel instanceof DependencyModel) {
     dependency.setFModel(fmodel);
     dependency.getFieldEditor().setEnabled(false);
     constants.setFModel(null);
     if (currentEditor != dependency) {
       currentEditor = dependency;
       enableComponent(1);
     }
   } else if (currentEditor != null) {
     currentEditor = null;
     enableComponent(-1);
     constants.setFModel(null);
     constants.setFModel(null);
   }
   selectedModel = fmodel;
   control.getParent().update();
   control.update();
   control.layout(true);
   control.redraw();
 }
Exemplo n.º 5
0
  /**
   * This method creates the SWT elements for an explorer
   *
   * @param parent Parent is the base composite
   */
  protected Control createContents(Composite parent) {

    parent.setBounds(0, 0, 550, 500);

    // upper sash
    SashForm sash = new SashForm(parent, SWT.VERTICAL | SWT.NULL);
    sash.setBounds(0, 0, 550, 480);
    // lower sash
    SashForm sash_form = new SashForm(sash, SWT.VERTICAL | SWT.NULL);
    sash_form.setBounds(0, 0, 200, 200);

    Composite composite = new Composite(sash, SWT.NONE);
    composite.setBounds(0, 0, 345, 220);

    final Label label = new Label(composite, SWT.NONE);
    label.setBounds(15, 15, 60, 20);
    label.setText("Root:");

    final Combo combo = new Combo(composite, SWT.NONE);
    combo.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            tv.setInput(new File(combo.getText()));
          }
        });
    combo.setBounds(80, 10, 100, 20);
    File[] roots = File.listRoots();
    for (int i = 0; i < roots.length; i++) {
      combo.add(roots[i].toString());
    }
    combo.select(0);

    // explorer
    tv = new TreeViewer(sash_form);
    tv.setContentProvider(new FileTreeContentProvider());
    tv.setLabelProvider(new FileTreeLabelProvider());
    tv.setInput(new File(combo.getText()));

    final Label labelFile = new Label(composite, SWT.NONE);
    labelFile.setBounds(15, 45, 30, 25);
    if (buttonString.startsWith(saveString)) {
      labelFile.setText("Konfig:");
    } else {
      labelFile.setText("File:");
    }

    final Text fileName = new Text(composite, SWT.BORDER);
    fileName.setBounds(80, 40, 350, 25);

    final Label labelPath = new Label(composite, SWT.NONE);
    labelPath.setBounds(15, 75, 45, 25);
    labelPath.setText("Path:");

    final Label pathName = new Label(composite, SWT.NONE);
    pathName.setBounds(80, 75, 300, 25);

    if (buttonString.equals(loadString)) {
      final Label labedTemp = new Label(composite, SWT.NONE);
      labedTemp.setBounds(15, 230, 100, 25);
      labedTemp.setText("Temp:");

      textTemp = new Text(composite, SWT.BORDER);
      textTemp.setBounds(130, 230, 300, 25);
      textTemp.setText(Controller.loadTemp());

      final Label labelXargs = new Label(composite, SWT.NONE);
      labelXargs.setBounds(15, 195, 100, 25);
      labelXargs.setText("xargs template:");

      textXargs = new Text(composite, SWT.BORDER);
      textXargs.setBounds(130, 195, 300, 25);
      textXargs.setText(Controller.loadXarg());

      final Label labelLocal = new Label(composite, SWT.NONE);
      labelLocal.setBounds(15, 160, 100, 25);
      labelLocal.setText("Local deploy path:");

      textLocal = new Text(composite, SWT.BORDER);
      textLocal.setBounds(130, 160, 300, 25);
      textLocal.setText(Controller.loadLocal());
    }

    final Button exitButton = new Button(composite, SWT.NONE);
    exitButton.addMouseListener(
        new MouseAdapter() {
          public void mouseDown(MouseEvent e) {
            closeExplorer();
          }
        });
    exitButton.setBounds(50, 110, 100, 25);
    exitButton.setText("Cancel");

    if (buttonString == loadString) {
      final Button deployButton = new Button(composite, SWT.NONE);
      deployButton.addMouseListener(
          new MouseAdapter() {
            public void mouseDown(MouseEvent e) {

              String fullPath = "";

              char lastChar = pathName.getText().charAt(pathName.getText().length() - 1);
              if (lastChar != File.separatorChar) {
                pathName.setText(pathName.getText() + File.separatorChar);
              }

              if (fileName.getText().length() <= 0) {
                Controller.activateErrorView("choose a filename !");
                System.out.println("choose a filename !");
                return;
              }

              AmonemUI.amonemManager.setFolders(
                  textTemp.getText(), textLocal.getText(), textXargs.getText(), textTemp.getText());

              AmonemUI.amonemManager.importDAG(pathName.getText() + fileName.getText(), true);

              Controller.closeExplorer();
            }
          });
      deployButton.setBounds(270, 110, 100, 25);
      deployButton.setText("Deploy");
    }

    Button button = new Button(composite, 0);
    button.addMouseListener(
        new MouseAdapter() {
          public void mouseDown(MouseEvent e) {

            //				if(pathName.getText().length()<=0 || fileName.getText().length()<=0){
            //					System.out.println("path directory error");
            //					return;
            //				}

            String fullPath = "";
            //				if(pathName.getText().endsWith(String.valueOf(Path.SEPARATOR)) ||
            // pathName.getText().endsWith("\\")){
            //					fullPath = pathName.getText()+fileName.getText();
            //				}else{
            //					fullPath = pathName.getText()+String.valueOf(Path.SEPARATOR)+fileName.getText();
            //				}
            //				if(pathName.getText().lastIndexOf("/") != pathName.getText().firstIndexOf("/")){
            //
            //				}
            //				System.out.println(pathName.getText());
            //				System.out.println(fileName.getText());
            //				System.out.println(pathName.getText()+fileName.getText());
            //
            char lastChar = pathName.getText().charAt(pathName.getText().length() - 1);
            //				if(!(lastChar == Path.SEPARATOR || lastChar == '\\')){
            //					pathName.setText(pathName.getText()+Path.SEPARATOR);
            //				}

            if (lastChar != File.separatorChar) {
              pathName.setText(pathName.getText() + File.separatorChar);
            }

            // System.out.println(pathName.getText());

            if (buttonString == okString) {
              if (mode == DIRECTORY) {
                text.setText(pathName.getText());
              } else if (mode == FILE) {
                text.setText(pathName.getText() + fileName.getText());
              }
            } else {
              // fileName not needed
              if (buttonString == savePeerString) {
                AmonemUI.amonemManager.exportPeer(pathName.getText(), fieldName);
              }
              // fileName needed
              else {
                if (fileName.getText().length() <= 0) {
                  Controller.activateErrorView("choose a filename !");
                  System.out.println("choose a filename !");
                  return;
                }
                // System.out.println(pathName.getText()+Path.SEPARATOR+fileName.getText());
                if (buttonString == loadString) {
                  AmonemUI.amonemManager.importDAG(pathName.getText() + fileName.getText(), false);
                } else if (buttonString == saveString) {
                  AmonemUI.amonemManager.exportDAG(pathName.getText(), fileName.getText());
                }
              }
            }
            Controller.closeExplorer();
          }
        });
    button.setBounds(160, 110, 100, 25);
    button.setText(buttonString);

    tv.addSelectionChangedListener(
        new ISelectionChangedListener() {
          public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            File selected_file = (File) selection.getFirstElement();
            if (selected_file.isDirectory()) {
              pathName.setText(selected_file.toString());
              fileName.setText("");
            }
            if (selected_file.isFile()) {
              fileName.setText(selected_file.getName());
              pathName.setText(
                  selected_file
                      .toString()
                      .substring(
                          0, selected_file.toString().length() - selected_file.getName().length()));
            }
          }
        });

    parent.pack();
    parent.update();

    return sash;
  }