@Override
 protected void configureShell(Shell newShell) {
   super.configureShell(newShell);
   if (system) {
     newShell.setText(Messages.getString("ShowRoutineItemsDialog.systemTitle")); // $NON-NLS-1$
   } else {
     newShell.setText(Messages.getString("ShowRoutineItemsDialog.title")); // $NON-NLS-1$
   }
 }
 private boolean getPropagate(Boolean returnIfNull) {
   if (propagate == null) {
     if (returnIfNull != null) {
       return returnIfNull;
     }
     propagate =
         MessageDialog.openQuestion(
             new Shell(),
             Messages.getString("ChangeMetadataCommand.messageDialog.propagate"), // $NON-NLS-1$
             Messages.getString(
                 "ChangeMetadataCommand.messageDialog.questionMessage")); //$NON-NLS-1$
   }
   return propagate;
 }
  @Override
  protected void doRun() {
    ISelection selection = getSelection();
    Object obj = ((IStructuredSelection) selection).getFirstElement();
    RepositoryNode node = (RepositoryNode) obj;

    IPath path = RepositoryNodeUtilities.getPath(node);
    String originalName = node.getObject().getLabel();

    RepositoryObject repositoryObj = new RepositoryObject(node.getObject().getProperty());
    repositoryObj.setRepositoryNode(node.getObject().getRepositoryNode());
    OpenExistVersionProcessWizard wizard = new OpenExistVersionProcessWizard(repositoryObj);
    PropertyManagerWizardDialog dialog =
        new PropertyManagerWizardDialog(Display.getCurrent().getActiveShell(), wizard);
    dialog.setPageSize(300, 250);
    dialog.setTitle(Messages.getString("OpenExistVersionProcess.open.dialog")); // $NON-NLS-1$
    if (dialog.open() == Dialog.OK) {
      refresh(node);
      // refresh the corresponding editor's name
      IEditorPart part = getCorrespondingEditor(node);
      if (part != null && part instanceof IUIRefresher) {
        ((IUIRefresher) part).refreshName();
      } else {
        processRoutineRenameOperation(originalName, node, path);
      }
    }
  }
  /**
   * Test if the selected item is a node.
   *
   * @return true / false
   */
  private boolean canPerformAction() {
    if (getSelectedObjects().isEmpty()) {
      return false;
    }
    List parts = getSelectedObjects();
    if (parts.size() == 1) {
      Object o = parts.get(0);
      if (!(o instanceof NodePart)) {
        return false;
      }
      NodePart part = (NodePart) o;
      if (!(part.getModel() instanceof INode)) {
        return false;
      }
      node = (Node) part.getModel();

      EditPart parentPart = part.getParent();
      while (!(parentPart instanceof ProcessPart)) {
        parentPart = parentPart.getParent();
      }
      if (!(parentPart instanceof ProcessPart)) {
        return false;
      }
      process = (IProcess) ((ProcessPart) parentPart).getModel();
      setText(Messages.getString("PropertiesContextAction.Properties")); // $NON-NLS-1$
    }
    return true;
  }
 /*
  * (non-Javadoc)
  *
  * @see
  * org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createCommand()
  */
 public Command createCommand(Button button) {
   Object data = button.getData(NAME);
   if (data != null) {
     if (ICON_SELECTION.equals(data)) {
       FileDialog dial = new FileDialog(composite.getShell(), SWT.NONE);
       dial.setFilterExtensions(
           new String[] {"*.jpg", "*.png", "*.gif"}); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
       String propertyName = (String) button.getData(PARAMETER_NAME);
       String file = dial.open();
       if (file != null) {
         if (!file.equals("")) { // $NON-NLS-1$
           if (!elem.getPropertyValue(propertyName).equals(file)) {
             ImageData imageData = new ImageData(file);
             if (ImageUtils.checkSize(
                 ImageDescriptor.createFromImageData(imageData), ImageUtils.ICON_SIZE.ICON_32)) {
               if (elem instanceof IProcess2) {
                 refreshIcon(imageData);
                 return new IconSelectionCommand(
                     (IProcess2) elem, ImageDescriptor.createFromImageData(imageData), file);
               }
             } else {
               MessageDialog.openError(
                   composite.getShell(),
                   Messages.getString("IconSelectionController.MessageTitle"), // $NON-NLS-1$
                   Messages.getString("IconSelectionController.Messages")); // $NON-NLS-1$
             }
           }
         }
       }
     } else if (ICON_REVERT.equals(data)) {
       if (elem instanceof IProcess2) {
         Image defaultIcon = RepositoryLabelProvider.getDefaultJobletImage();
         ImageDescriptor imageData = ImageDescriptor.createFromImage(defaultIcon);
         refreshIcon(defaultIcon.getImageData());
         return new IconSelectionCommand((IProcess2) elem, imageData, null);
       }
     }
   }
   return null;
 }
  public void init(
      INode node,
      IElementParameter schemaParam,
      IMetadataTable currentOutputMetadata,
      IMetadataTable newOutputMetadata) {
    this.node = node;
    this.schemaParam = schemaParam;
    if (schemaParam == null) {
      if (newOutputMetadata.getAttachedConnector() != null) {
        currentConnector = newOutputMetadata.getAttachedConnector();
      } else {
        if (node.isELTComponent()) {
          currentConnector = EConnectionType.TABLE.getName();
        } else {
          currentConnector = EConnectionType.FLOW_MAIN.getName();
        }
      }
      for (IElementParameter param : node.getElementParameters()) {
        if (param.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE)
            && param.getContext().equals(currentConnector)) {
          this.schemaParam = param;
        }
      }
    } else {
      currentConnector = this.schemaParam.getContext();
    }

    this.inputNode = null;
    this.currentInputMetadata = null;
    this.newInputMetadata = null;
    oldInputMetadata = null;
    this.currentOutputMetadata = currentOutputMetadata;
    if (this.currentOutputMetadata == null) {
      this.currentOutputMetadata = node.getMetadataFromConnector(currentConnector);
    }
    if (currentOutputMetadata == null && newOutputMetadata != null) {
      currentOutputMetadata = newOutputMetadata.clone(true);
    }
    oldOutputMetadata = this.currentOutputMetadata.clone(true);
    this.newOutputMetadata = newOutputMetadata.clone(true);
    this.newOutputMetadata.setReadOnly(this.currentOutputMetadata.isReadOnly());
    initializeContainer();
    setLabel(Messages.getString("ChangeMetadataCommand.changeMetadataValues")); // $NON-NLS-1$
  }
 public ChangeMetadataCommand(
     INode node,
     IElementParameter schemaParam,
     INode inputNode,
     IMetadataTable currentInputMetadata,
     IMetadataTable newInputMetadata,
     IMetadataTable currentOutputMetadata,
     IMetadataTable newOutputMetadata) {
   this.node = node;
   this.inputNode = inputNode;
   this.schemaParam = schemaParam;
   if (schemaParam == null) {
     currentConnector = EConnectionType.FLOW_MAIN.getName();
     for (IElementParameter param : node.getElementParameters()) {
       if ((param.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE)
               || param.getFieldType().equals(EParameterFieldType.DCSCHEMA))
           && param.getContext().equals(currentConnector)) {
         this.schemaParam = param;
       }
     }
   } else {
     currentConnector = this.schemaParam.getContext();
   }
   this.currentInputMetadata = currentInputMetadata;
   if (currentInputMetadata != null) {
     oldInputMetadata = currentInputMetadata.clone();
   } else {
     oldInputMetadata = null;
   }
   this.newInputMetadata = newInputMetadata;
   this.currentOutputMetadata = currentOutputMetadata;
   if (this.currentOutputMetadata == null) {
     this.currentOutputMetadata = node.getMetadataFromConnector(currentConnector);
   }
   oldOutputMetadata = this.currentOutputMetadata.clone();
   this.newOutputMetadata = newOutputMetadata;
   initializeContainer();
   setLabel(Messages.getString("ChangeMetadataCommand.changeMetadataValues")); // $NON-NLS-1$
 }
/** DOC xye class global comment. Detailled comment */
public class OpenExistVersionProcessAction extends EditPropertiesAction {

  private static final String ACTION_LABEL =
      Messages.getString("OpenExistVersionProcess.open"); // $NON-NLS-1$

  public OpenExistVersionProcessAction() {
    super();

    this.setText(ACTION_LABEL);
    this.setToolTipText(ACTION_LABEL);
    this.setImageDescriptor(ImageProvider.getImageDesc(ECoreImage.PROCESS_ICON));
  }

  @Override
  protected void doRun() {
    ISelection selection = getSelection();
    Object obj = ((IStructuredSelection) selection).getFirstElement();
    RepositoryNode node = (RepositoryNode) obj;

    IPath path = RepositoryNodeUtilities.getPath(node);
    String originalName = node.getObject().getLabel();

    RepositoryObject repositoryObj = new RepositoryObject(node.getObject().getProperty());
    repositoryObj.setRepositoryNode(node.getObject().getRepositoryNode());
    OpenExistVersionProcessWizard wizard = new OpenExistVersionProcessWizard(repositoryObj);
    PropertyManagerWizardDialog dialog =
        new PropertyManagerWizardDialog(Display.getCurrent().getActiveShell(), wizard);
    dialog.setPageSize(300, 250);
    dialog.setTitle(Messages.getString("OpenExistVersionProcess.open.dialog")); // $NON-NLS-1$
    if (dialog.open() == Dialog.OK) {
      refresh(node);
      // refresh the corresponding editor's name
      IEditorPart part = getCorrespondingEditor(node);
      if (part != null && part instanceof IUIRefresher) {
        ((IUIRefresher) part).refreshName();
      } else {
        processRoutineRenameOperation(originalName, node, path);
      }
    }
  }

  @Override
  public void init(TreeViewer viewer, IStructuredSelection selection) {
    if (!ExtractMetaDataUtils.getInstance().haveLoadMetadataNode()) {
      setEnabled(false);
      return;
    }
    super.init(viewer, selection);
  }

  public class PropertyManagerWizardDialog extends WizardDialog {

    /**
     * DOC xye PropertyManagerWizardDialog constructor comment.
     *
     * @param parentShell
     * @param newWizard
     */
    public PropertyManagerWizardDialog(Shell parentShell, IWizard newWizard) {
      super(parentShell, newWizard);
    }

    public Button getFinishButton() {
      return getButton(IDialogConstants.FINISH_ID);
    }
  }

  @Override
  protected IEditorPart getCorrespondingEditor(RepositoryNode node) {
    IEditorReference[] eidtors = getActivePage().getEditorReferences();

    for (IEditorReference eidtor : eidtors) {
      try {
        IEditorInput input = eidtor.getEditorInput();
        if (!(input instanceof JobEditorInput)) {
          continue;
        }

        JobEditorInput repositoryInput = (JobEditorInput) input;
        checkUnLoadedNodeForProcess(repositoryInput);
        if (repositoryInput.getItem().equals(node.getObject().getProperty().getItem())) {

          IPath path = repositoryInput.getFile().getLocation();

          return eidtor.getEditor(false);
        }
      } catch (PartInitException e) {
        continue;
      }
    }
    return null;
  }

  private void checkUnLoadedNodeForProcess(JobEditorInput fileEditorInput) {
    if (fileEditorInput == null || fileEditorInput.getLoadedProcess() == null) {
      return;
    }
    IProcess2 loadedProcess = fileEditorInput.getLoadedProcess();
    List<NodeType> unloadedNode = loadedProcess.getUnloadedNode();
    if (unloadedNode != null && !unloadedNode.isEmpty()) {

      String message = "Some Component are not loaded:\n";
      for (int i = 0; i < unloadedNode.size(); i++) {
        message = message + unloadedNode.get(i).getComponentName() + "\n";
      }
      if (!CommonsPlugin.isHeadless() && PlatformUI.isWorkbenchRunning()) {
        Display display = Display.getCurrent();
        if (display == null) {
          display = Display.getDefault();
        }
        if (display != null) {
          final Display tmpDis = display;
          final String tmpMess = message;
          display.syncExec(
              new Runnable() {

                @Override
                public void run() {
                  Shell shell = null;
                  final IWorkbenchWindow activeWorkbenchWindow =
                      PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                  if (activeWorkbenchWindow != null) {
                    shell = activeWorkbenchWindow.getShell();
                  } else {
                    if (tmpDis != null) {
                      shell = tmpDis.getActiveShell();
                    } else {
                      shell = new Shell();
                    }
                  }
                  MessageDialog.openWarning(shell, "Warning", tmpMess);
                }
              });
        }
      }
    }
  }
}
Пример #9
0
/**
 * Toggle whether using the hightlight of subjobs or not, this action is only related to
 * MultiPageTalendEditor.
 */
public class ToggleSubjobsAction extends Action {

  public static final String ID =
      "org.talend.designer.core.ui.action.ToggleSubjobsAction"; //$NON-NLS-1$

  private static final String JOBLET_ID = "org.talend.designer.joblet.multieditor"; // $NON-NLS-1$

  private static final String MAP_REDUCE_MULTIPAGE_EDITOR_ID =
      "org.talend.designer.mapreduce.editor"; //$NON-NLS-1$

  public static final String TEXT = Messages.getString("ToggleSubjobsAction.LABEL"); // $NON-NLS-1$

  private static ToggleSubjobsAction instance = new ToggleSubjobsAction();

  public static ToggleSubjobsAction getDefault() {
    return instance;
  }

  /** bqian ToggleSubjobsAction constructor comment. */
  private ToggleSubjobsAction() {
    super(TEXT, IAction.AS_CHECK_BOX);
    this.setId(ID);
    this.setDescription(TEXT);
    setChecked(getGlobalStore().getBoolean(TalendDesignerPrefConstants.DISPLAY_SUBJOBS));
  }

  @Override
  public void run() {
    boolean display = isChecked();
    getGlobalStore().setValue(TalendDesignerPrefConstants.DISPLAY_SUBJOBS, display);

    IEditorReference[] editorParts =
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();

    for (IEditorReference reference : editorParts) {
      if (!(reference.getId().equals(MultiPageTalendEditor.ID)
          || reference.getId().equals(JOBLET_ID)
          || MAP_REDUCE_MULTIPAGE_EDITOR_ID.equals(reference.getId()))) {
        continue;
      }

      IEditorPart editorPart = reference.getEditor(false);
      if (editorPart == null) {
        continue;
      }
      if (editorPart instanceof AbstractMultiPageTalendEditor) {
        AbstractMultiPageTalendEditor editor = (AbstractMultiPageTalendEditor) editorPart;
        IProcess2 process = editor.getTalendEditor().getProcess();

        if (process == null) {
          continue;
        }
        List<? extends ISubjobContainer> subjobs = process.getSubjobContainers();

        for (ISubjobContainer subjobContainer : subjobs) {
          subjobContainer.updateSubjobDisplay();
        }
      }
    }
  }

  private IPreferenceStore getGlobalStore() {
    return DesignerPlugin.getDefault().getPreferenceStore();
  }
}
Пример #10
0
 /**
  * Move the given node to another location.
  *
  * @param node
  * @param newPos
  */
 public MoveNoteCommand(Note note, Point newPos) {
   this.note = note;
   this.newPos = newPos;
   setLabel(Messages.getString("MoveNodeCommand.Label")); // $NON-NLS-1$
 }
 /**
  * Constructs a new PropertiesContextAction.
  *
  * @param part
  */
 public ShowComponentSettingViewerAction(IWorkbenchPart part) {
   super(part);
   setId(ID);
   setImageDescriptor(DesignerPlugin.getImageDescriptor("icons/breakpoint.png")); // $NON-NLS-1$
   setText(Messages.getString("PropertiesContextAction.Properties")); // $NON-NLS-1$
 }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createControl()
   */
  @Override
  public Control createControl(
      final Composite subComposite,
      final IElementParameter param,
      final int numInRow,
      final int nbInRow,
      final int top,
      final Control lastControl) {
    this.curParameter = param;
    FormData data;
    Button btnEdit = getWidgetFactory().createButton(subComposite, "", SWT.PUSH); // $NON-NLS-1$

    btnEdit.setImage(ImageProvider.getImage(CoreUIPlugin.getImageDescriptor(DOTS_BUTTON)));

    data = new FormData();
    data.left = new FormAttachment(0, 120);
    data.top = new FormAttachment(0, top);
    data.height = STANDARD_HEIGHT - 2;
    btnEdit.setLayoutData(data);
    btnEdit.setData(NAME, ICON_SELECTION);
    btnEdit.setData(PARAMETER_NAME, param.getName());
    btnEdit.setEnabled(!param.isReadOnly());
    btnEdit.addSelectionListener(listenerSelection);

    DecoratedField dField =
        new DecoratedField(
            subComposite,
            SWT.NONE,
            new IControlCreator() {

              @Override
              public Control createControl(Composite parent, int style) {

                return new Label(parent, style);
              }
            });
    // revert btn
    Button btnRevert =
        getWidgetFactory()
            .createButton(
                subComposite,
                Messages.getString("IconSelectionController.Revert"),
                SWT.PUSH); //$NON-NLS-1$

    data = new FormData();
    data.left = new FormAttachment(btnEdit, 5);
    data.top = new FormAttachment(0, top);
    data.height = STANDARD_HEIGHT - 2;
    btnRevert.setLayoutData(data);
    btnRevert.setData(NAME, ICON_REVERT);
    btnRevert.setData(PARAMETER_NAME, param.getName());
    btnRevert.setEnabled(!param.isReadOnly());
    btnRevert.addSelectionListener(listenerSelection);

    if (param.isRequired()) {
      FieldDecoration decoration =
          FieldDecorationRegistry.getDefault()
              .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
      dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
    }
    if (param.isRepositoryValueUsed()) {
      FieldDecoration decoration =
          FieldDecorationRegistry.getDefault()
              .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
      decoration.setDescription(
          Messages.getString("FileController.decoration.description")); // $NON-NLS-1$
      dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.BOTTOM, false);
    }

    Control cLayout = dField.getLayoutControl();
    filePathText = (Label) dField.getControl();
    String file = (String) elem.getPropertyValue(PARAMETER_NAME);
    if (file != null) {
      // ImageData imageData = new ImageData(file);
      // image = new Image(composite.getShell().getDisplay(), imageData);
      // filePathText.setImage(image);
    }

    CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName(), 0);
    data = new FormData();
    if (lastControl != null) {
      data.left = new FormAttachment(lastControl, 0);
    } else {
      data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
    }
    data.top = new FormAttachment(0, top);
    labelLabel.setLayoutData(data);
    if (numInRow != 1) {
      labelLabel.setAlignment(SWT.RIGHT);
    }

    // **************************
    data = new FormData();
    int currentLabelWidth = 50;
    GC gc = new GC(labelLabel);
    Point labelSize = gc.stringExtent(param.getDisplayName());
    gc.dispose();

    if ((labelSize.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth) {
      currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE;
    }

    if (numInRow == 1) {
      if (lastControl != null) {
        data.left = new FormAttachment(lastControl, currentLabelWidth);
      } else {
        data.left = new FormAttachment(0, currentLabelWidth);
      }
    } else {
      data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
    }
    data.top = new FormAttachment(btnEdit, 0, SWT.CENTER);
    data.height = 34;
    data.width = 30;
    cLayout.setLayoutData(data);

    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return btnEdit;
  }