Ejemplo n.º 1
0
        public void selectionChanged(SelectionChangedEvent event) {
          IStructuredSelection selection = (IStructuredSelection) event.getSelection();

          try {
            myFileNameText.removeModifyListener(FNAME_LISTENER);

            IResource resource;
            if (selection == null) {
              resource = null;
              myFileNameText.setText(""); // $NON-NLS-1$
            } else {
              resource = (IResource) selection.getFirstElement();
              if (resource instanceof IFile) {
                myFileNameText.setText(resource.getName());
                myFileNameText.setEnabled(false);
              } else {
                if (myOnlyExisting) {
                  myFileNameText.setText(""); // $NON-NLS-1$
                  myFileNameText.setEnabled(false);
                } else {
                  myFileNameText.setEnabled(true);
                  IPath computePath = IPathUtils.computePath(myResource, myFileNameText.getText());
                  if (computePath != null && myDefaultFileName != null) {
                    IFile file = WorkspaceUtils.getWorkspaceFile(computePath.toString());
                    if (file != null && file.exists()) {
                      myFileNameText.setText(myDefaultFileName);
                    }
                  }
                }
              }
            }

            myResource = resource;
            myPath = IPathUtils.computePath(myResource, myFileNameText.getText());
            fileSelectionChanged(myPath);
          } finally {
            myFileNameText.addModifyListener(FNAME_LISTENER);
          }
        }
Ejemplo n.º 2
0
 public void modifyText(ModifyEvent e) {
   myFileName = myFileNameText.getText();
   myPath = IPathUtils.computePath(myResource, myFileName);
   fileSelectionChanged(myPath);
 }