protected void directoryNameChanged() {
    if (!pageReady) {
      new UIJob(I18n.get("job")) {
        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
          directoryNameChanged();
          return Status.OK_STATUS;
        }
      }.schedule();
      return;
    }

    parent.getConfiguration().setPath(directoryText.getText());

    setPageComplete(false);
    modulesTable.clearAll();

    final File testFile = new File(directoryText.getText());
    if (!testFile.isDirectory()) {
      parent.getConfiguration().clearModules();
      refreshModuleList();
      return;
    }

    setMessage(I18n.get("processing"), WizardPage.INFORMATION);

    new Job(I18n.get("job")) {

      @Override
      protected IStatus run(IProgressMonitor monitor) {
        parsePath(testFile);
        return Status.OK_STATUS;
      }
    }.schedule();
  }
  private void dialogChanged() {
    if (!pageReady) {
      new UIJob(I18n.get("job")) {
        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
          dialogChanged();
          return Status.OK_STATUS;
        }
      }.schedule();
      return;
    }

    shopChanged();
    websiteChanged();
    defaultChanged();

    if (!Pattern.matches("^[a-zA-Z0-9_]+$", nameCombo.getText())) {
      updateStatus(I18n.get("wrong_name"));
      return;
    }
    if (labelText.getText().length() == 0) {
      updateStatus(I18n.get("empty_label"));
      return;
    }
    updateStatus(null);
  }
 public ImportWizardPage(String pageName, ModuleImportWizard parent) {
   super(pageName);
   this.parent = parent;
   setPageComplete(false);
   setTitle(I18n.get("title")); // NON-NLS-1
   setDescription(I18n.get("description")); // NON-NLS-1
   apps = new ArrayList<File>();
 }
  public void refreshModuleList() {
    if (!pageReady) {
      new UIJob(I18n.get("job")) {
        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
          refreshModuleList();
          return Status.OK_STATUS;
        }
      }.schedule();
      return;
    }

    modulesTable.removeAll();

    for (ImportedModule module : parent.getConfiguration().getModules()) {
      TableItem item = new TableItem(modulesTable, NONE);
      item.setText(module.toString());
      System.out.println(module.toString());

      /*
       * TODO: populate table with module names
       */
    }

    if (parent.getConfiguration().getModules().length > 0) {
      setPageComplete(true);
    }
  }
  protected void nameChanged() {
    if (!pageReady) {
      new UIJob(I18n.get("job")) {
        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
          nameChanged();
          return Status.OK_STATUS;
        }
      }.schedule();
      return;
    }

    getConfig().setGroupName(nameCombo.getText());
    parent.getFiledPage().initialize(nameCombo.getText());
    GroupData group =
        getConfig().getModule().getConfigGroup(getConfig().getSectionName(), nameCombo.getText());
    if (group != null) {
      labelText.setText(group.getLabel());
      sortOrderSpinner.setSelection(group.getSortOrder());
      defaultCheckbox.setSelection(group.isVisibleDefault());
      websiteCheckbox.setSelection(group.isVisibleWebsite());
      shopCheckbox.setSelection(group.isVisibleStore());
    } else {
      labelText.setText("");
      sortOrderSpinner.setSelection(0);
      defaultCheckbox.setSelection(false);
      websiteCheckbox.setSelection(false);
      shopCheckbox.setSelection(false);
    }
    dialogChanged();
  }
 protected void projectNameChanged() {
   if (!pageReady) {
     new UIJob(I18n.get("job")) {
       @Override
       public IStatus runInUIThread(IProgressMonitor monitor) {
         projectNameChanged();
         return Status.OK_STATUS;
       }
     }.schedule();
     return;
   }
   parent.getConfiguration().setProjectName(nameText.getText());
 }
 protected void copyFlagChanged() {
   if (!pageReady) {
     new UIJob(I18n.get("job")) {
       @Override
       public IStatus runInUIThread(IProgressMonitor monitor) {
         copyFlagChanged();
         return Status.OK_STATUS;
       }
     }.schedule();
     return;
   }
   parent.getConfiguration().setCopySource(copyToWorkspaceCheck.getSelection());
 }
  protected void defaultChanged() {
    if (!pageReady) {
      new UIJob(I18n.get("job")) {
        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
          defaultChanged();
          return Status.OK_STATUS;
        }
      }.schedule();
      return;
    }

    getConfig().setGroupShowDefault(defaultCheckbox.getSelection());
  }
  protected void sortOrderChanged() {
    if (!pageReady) {
      new UIJob(I18n.get("job")) {
        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
          sortOrderChanged();
          return Status.OK_STATUS;
        }
      }.schedule();
      return;
    }

    getConfig().setGroupSortOrder(sortOrderSpinner.getSelection());
  }
  protected void labelChanged() {
    if (!pageReady) {
      new UIJob(I18n.get("job")) {
        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
          labelChanged();
          return Status.OK_STATUS;
        }
      }.schedule();
      return;
    }

    getConfig().setGroupLabel(labelText.getText());
    dialogChanged();
  }
  public void initialize(final MagentoModule module, final String section) {
    if (!pageReady) {
      new UIJob(I18n.get("job")) {
        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
          initialize(module, section);
          return Status.OK_STATUS;
        }
      }.schedule();
      return;
    }

    String[] names = module.getConfigGroupNames(section);
    nameCombo.setItems(names);
    nameAutoComplete.setProposals(names);
  }
  protected void handleBrowseButton() {
    if (!pageReady) {
      new UIJob(I18n.get("job")) {
        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
          handleBrowseButton();
          return Status.OK_STATUS;
        }
      }.schedule();
      return;
    }

    DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.OPEN);
    String path = dialog.open();
    if (path != null) {
      directoryText.setText(path);
    }
  }
  @Override
  public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    container.setLayout(layout);
    layout.verticalSpacing = 9;
    setControl(container);

    Label directoryLabel = new Label(container, SWT.NONE);
    directoryLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    directoryLabel.setText(I18n.get("directory"));

    directoryText = new Text(container, SWT.BORDER);
    directoryText.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(ModifyEvent e) {
            directoryNameChanged();
          }
        });
    directoryText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    browseButton = new Button(container, SWT.NONE);
    browseButton.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseDown(MouseEvent e) {
            handleBrowseButton();
          }
        });
    browseButton.setText(I18n.get("browse"));

    Label nameLabel = new Label(container, SWT.NONE);
    nameLabel.setText(I18n.get("project_name"));

    nameText = new Text(container, SWT.BORDER);
    nameText.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(ModifyEvent e) {
            projectNameChanged();
          }
        });
    nameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);

    modulesTable = new Table(container, SWT.BORDER | SWT.FULL_SELECTION);
    modulesTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    modulesTable.setHeaderVisible(true);
    modulesTable.setLinesVisible(true);

    moduleNameColumn = new TableColumn(modulesTable, SWT.NONE);
    moduleNameColumn.setWidth(100);
    moduleNameColumn.setText(I18n.get("module_name"));
    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);

    copyToWorkspaceCheck = new Button(container, SWT.CHECK);
    copyToWorkspaceCheck.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetDefaultSelected(SelectionEvent e) {
            copyFlagChanged();
          }

          @Override
          public void widgetSelected(SelectionEvent e) {
            copyFlagChanged();
          }
        });
    copyToWorkspaceCheck.setSelection(true);
    copyToWorkspaceCheck.setText(I18n.get("copy_to_workspace"));
    new Label(container, SWT.NONE);

    pageReady = true;
  }
  public void parsePath(File directory) {
    parent.getConfiguration().clearModules();
    apps.clear();
    lookForAppFolder(directory);
    if (apps.size() == 0) {
      new UIJob(I18n.get("ejjoj")) {
        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
          setMessage(I18n.get("no_app_folders"));
          return Status.OK_STATUS;
        }
      }.schedule();
    } else if (apps.size() > 1) {
      new UIJob(I18n.get("ejjoj")) {
        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
          setErrorMessage(I18n.get("multiple_app_folders"));
          return Status.OK_STATUS;
        }
      }.schedule();
    } else {
      File app = apps.get(0);
      StringBuilder path = new StringBuilder(app.getAbsolutePath());
      if (path.charAt(path.length() - 1) != '/') {
        path.append('/');
      }
      path.append(FolderHelper.ETC_FOLDER);
      path.append('/');
      path.append(FolderHelper.MODULES_FOLDER);
      System.out.println(path.toString());
      File modules = new File(path.toString());

      if (modules.isDirectory()) {
        File[] moduleList = modules.listFiles();
        if (moduleList != null) {
          for (File module : moduleList) {
            ImportedModule[] imported = ImportedModule.parseXmlFile(module, app);
            for (ImportedModule impModule : imported) {
              parent.getConfiguration().addModule(impModule);
            }
          }
        }
      }
      new UIJob(I18n.get("ejjoj")) {
        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
          setErrorMessage(null);
          setMessage(null);
          return Status.OK_STATUS;
        }
      }.schedule();
    }

    new UIJob(I18n.get("refresh")) {
      @Override
      public IStatus runInUIThread(IProgressMonitor monitor) {
        refreshModuleList();
        return Status.OK_STATUS;
      }
    }.schedule();
  }
  @Override
  public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    container.setLayout(layout);
    layout.numColumns = 2;
    layout.verticalSpacing = 9;
    setControl(container);

    Label nameLabel = new Label(container, SWT.NONE);
    nameLabel.setText(I18n.get("name"));

    nameCombo = new Combo(container, SWT.NONE);
    nameAutoComplete = new AutoCompleteField(nameCombo, new ComboContentAdapter(), new String[] {});
    nameCombo.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(ModifyEvent e) {
            nameChanged();
          }
        });
    nameCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label labelLabel = new Label(container, SWT.NONE);
    labelLabel.setText(I18n.get("label"));

    labelText = new Text(container, SWT.BORDER);
    labelText.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(ModifyEvent e) {
            labelChanged();
          }
        });
    labelText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label visibleLabel = new Label(container, SWT.NONE);
    visibleLabel.setText(I18n.get("visible"));

    SashForm sashForm = new SashForm(container, SWT.NONE);
    sashForm.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));

    defaultCheckbox = new Button(sashForm, SWT.CHECK);
    defaultCheckbox.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetDefaultSelected(SelectionEvent e) {
            defaultChanged();
          }

          @Override
          public void widgetSelected(SelectionEvent e) {
            defaultChanged();
          }
        });
    defaultCheckbox.setText(I18n.get("default"));

    websiteCheckbox = new Button(sashForm, SWT.CHECK);
    websiteCheckbox.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            websiteChanged();
          }

          @Override
          public void widgetDefaultSelected(SelectionEvent e) {
            websiteChanged();
          }
        });
    websiteCheckbox.setText(I18n.get("website"));

    shopCheckbox = new Button(sashForm, SWT.CHECK);
    shopCheckbox.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetDefaultSelected(SelectionEvent e) {
            shopChanged();
          }

          @Override
          public void widgetSelected(SelectionEvent e) {
            shopChanged();
          }
        });
    shopCheckbox.setText(I18n.get("shop"));
    sashForm.setWeights(new int[] {1, 1, 1});

    Label sortOrderLabel = new Label(container, SWT.NONE);
    sortOrderLabel.setText(I18n.get("sort_order"));

    sortOrderSpinner = new Spinner(container, SWT.BORDER);
    sortOrderSpinner.setMaximum(10000);
    sortOrderSpinner.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(ModifyEvent e) {
            sortOrderChanged();
          }
        });
    pageReady = true;
    dialogChanged();
  }
 public GroupPage(NewStoreConfigWizard newStoreConfigWizard) {
   super("wizardPage");
   setTitle(I18n.get("title"));
   setDescription(I18n.get("description"));
   parent = newStoreConfigWizard;
 }