@Override
  public boolean performOk() {
    CorePlugin.setECLEditorLineWidth(Integer.parseInt(textMaxLineWidth.getText()));
    CorePlugin.setECLEditorIndent(Integer.parseInt(textIndent.getText()));

    return super.performOk();
  }
  @Override
  protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(2, false));
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    textMaxLineWidth =
        createText(
            composite,
            Messages.ECLPreferenceEditorPage_MaximumLineWidth,
            Integer.toString(CorePlugin.getECLEditorLineWidth()));

    textIndent =
        createText(
            composite,
            Messages.ECLPreferenceEditorPage_Indent,
            Integer.toString(CorePlugin.getECLEditorIndent()));

    return null;
  }
Beispiel #3
0
 public void close() throws CoreException {
   closed.compareAndSet(false, true);
   try {
     if (!Thread.currentThread().isInterrupted()) {
       commands.put(CLOSE_NODE);
     } else {
       processingThread.interrupt();
     }
     closeSocket();
   } catch (Throwable e) {
     CorePlugin.log(e);
   }
 }
  // TODO ! need new presentation of set-text-selection command or hide args
  protected void convertSimple(Command command, ICommandFormatter formatter, boolean hasInput) {
    String commandName = CoreUtils.getScriptletNameByClass(command.eClass());
    formatter.addCommandName(commandName);

    Map<EStructuralFeature, Command> bindingMap = new HashMap<EStructuralFeature, Command>();
    for (Binding b : command.getBindings()) {
      bindingMap.put(b.getFeature(), b.getCommand());
    }

    List<EStructuralFeature> attributes = CoreUtils.getFeatures(command.eClass());

    boolean forced = false;
    boolean bigTextCommand =
        commandName.equals("upload-file") || commandName.equals("match-binary");

    for (EStructuralFeature feature : attributes) {
      if (feature.getEAnnotation(CoreUtils.INTERNAL_ANN) != null) continue;
      if (feature.getEAnnotation(CoreUtils.INPUT_ANN) != null && hasInput) continue;
      String name = feature.getName();
      if (isForced(commandName, name)) forced = true;
      Object val = command.eGet(feature);
      boolean skippped = true;
      Object defaultValue = feature.getDefaultValue();
      boolean isDefault = val == null || val.equals(defaultValue);
      if (!isDefault) {
        if (feature instanceof EAttribute) {
          EAttribute attr = (EAttribute) feature;
          String type = attr.getEAttributeType().getInstanceTypeName();
          if (val instanceof List<?>) {
            List<?> list = (List<?>) val;
            for (Object o : list) {
              String value = convertValue(o, type);
              if (value != null) {
                formatter.addAttrName(name, forced);
                formatter.addAttrValue(value);
                skippped = false;
              }
            }
          } else {
            if (val.equals(true)) {
              forced = true;
              formatter.addAttrName(name, forced);
            } else {
              String value = convertValue(val, type);
              if (value != null) {
                formatter.addAttrName(name, forced);
                if (bigTextCommand) formatter.addAttrValueWithLineBreak(value);
                else formatter.addAttrValue(value);
                skippped = false;
              }
            }
          }
        } else {
          EReference ref = (EReference) feature;
          EClass eclass = ref.getEReferenceType();
          if (eclass.getEPackage() == CorePackage.eINSTANCE
              && eclass.getClassifierID() == CorePackage.COMMAND) {
            boolean singleLine = !(val instanceof Sequence);
            formatter.addAttrName(name, forced);
            formatter.openGroup(singleLine);
            doConvert((Command) val, formatter, true);
            formatter.closeGroup(singleLine);
            skippped = false;
          } else {
            IParamConverter<?> converter =
                ParamConverterManager.getInstance().getConverter(eclass.getInstanceClass());
            if (converter != null) {
              try {
                String strVal = String.format("\"%s\"", converter.convertToCode(val));
                formatter.addAttrValue(strVal);
              } catch (CoreException e) {
                CorePlugin.log(e.getStatus());
              }
            }
          }
        }
      } else {
        Command c = bindingMap.get(feature);
        if (c != null) {
          formatter.addAttrName(name, forced);
          formatter.openExec();
          doConvert(c, formatter, hasInput);
          formatter.closeExec();
          skippped = false;
        }
      }
      if (skippped) forced = true;
    }
  }