private void disableCronFields() {
   cron.setVisible(false);
   cronLbl.setVisible(false);
   GridData gd = (GridData) cron.getLayoutData();
   gd.exclude = true;
   GridData gdlbl = (GridData) cronLbl.getLayoutData();
   gdlbl.exclude = true;
   triggerSection.setExpanded(false);
   triggerSection.setExpanded(true);
 }
示例#2
0
 private void showLoadFromEditorComponents(boolean b) {
   if (b) {
     GridData ldata = (GridData) comboEditorInputSelector.getLayoutData();
     ldata.exclude = !b;
     comboEditorInputSelector.setVisible(b);
     pageComposite.layout(new Control[] {comboEditorInputSelector});
   } else {
     GridData ldata = (GridData) comboEditorInputSelector.getLayoutData();
     ldata.exclude = !b;
     comboEditorInputSelector.setVisible(b);
     pageComposite.layout(new Control[] {comboEditorInputSelector});
   }
 }
示例#3
0
 private void showLoadFromFileComponents(boolean b, String fileName) {
   if (b) {
     GridData ldata = (GridData) compFileInputDetails.getLayoutData();
     ldata.exclude = !b;
     compFileInputDetails.setVisible(b);
     lblFilenametxt.setText(fileName);
     pageComposite.layout(new Control[] {lblFilenametxt, linkChangeFile, compFileInputDetails});
   } else {
     GridData ldata = (GridData) compFileInputDetails.getLayoutData();
     ldata.exclude = !b;
     compFileInputDetails.setVisible(b);
     pageComposite.layout(new Control[] {lblFilenametxt, linkChangeFile, compFileInputDetails});
   }
 }
 private void disableSimpleFields() {
   countLbl.setVisible(false);
   count.setVisible(false);
   intervalLbl.setVisible(false);
   interval.setVisible(false);
   GridData gd = (GridData) count.getLayoutData();
   gd.exclude = true;
   GridData gdlbl = (GridData) countLbl.getLayoutData();
   gdlbl.exclude = true;
   GridData gdEvent = (GridData) interval.getLayoutData();
   gdEvent.exclude = true;
   GridData gdeventlbl = (GridData) intervalLbl.getLayoutData();
   gdeventlbl.exclude = true;
   triggerSection.setExpanded(false);
   triggerSection.setExpanded(true);
 }
  private void checkPage() {
    try {
      upstreamConfigComponent.setUpstreamConfig(upstreamConfig);

      boolean showUpstreamConfig =
          sourceRefName.startsWith(Constants.R_HEADS)
              || sourceRefName.startsWith(Constants.R_REMOTES);
      Composite container = upstreamConfigComponent.getContainer();
      GridData gd = (GridData) container.getLayoutData();
      if (gd.exclude == showUpstreamConfig) {
        gd.exclude = !showUpstreamConfig;
        container.setVisible(showUpstreamConfig);
        container.getParent().layout(true);
        ensurePreferredHeight(getShell());
      }

      boolean basedOnLocalBranch = sourceRefName.startsWith(Constants.R_HEADS);
      if (basedOnLocalBranch && upstreamConfig != UpstreamConfig.NONE)
        setMessage(UIText.CreateBranchPage_LocalBranchWarningMessage, IMessageProvider.INFORMATION);

      if (sourceRefName.length() == 0) {
        setErrorMessage(UIText.CreateBranchPage_MissingSourceMessage);
        return;
      }
      String message = this.myValidator.isValid(nameText.getText());
      if (message != null) {
        setErrorMessage(message);
        return;
      }

      setErrorMessage(null);
    } finally {
      setPageComplete(getErrorMessage() == null && nameText.getText().length() > 0);
    }
  }
示例#6
0
 /**
  * excludes a control from the Layout calculation
  *
  * @param that
  * @param hideit
  */
 private void hideObject(final Control that, final boolean hideit) {
   GridData GData = (GridData) that.getLayoutData();
   GData.exclude = true && hideit;
   that.setVisible(true && !hideit);
   Control[] myArray = {that};
   layout(myArray);
 }
示例#7
0
  public void remove(MUFModule module) {
    if (playing) {
      delayRemove.offer(module);
      return;
    }

    // set to true
    playing = true;
    adding = false;
    moduleToBeRemoved = module;

    // exclude from layout
    modules.remove(module.getId());
    GridData data = (GridData) module.self.getLayoutData();
    data.exclude = true;
    module.self.setLayoutData(data);
    module.self.setVisible(false);

    if (content.isVisible()) {
      // get destination size
      frame = 1;
      Point newSize = content.computeSize(SWT.DEFAULT, SWT.DEFAULT);
      dx = Math.min(0, (newSize.x - oldSize.x) / FRAMES);
      dy = Math.min(0, (newSize.y - oldSize.y) / FRAMES);
      Display.getCurrent().timerExec(0, runnable);
    } else {
      oldSize = content.computeSize(SWT.DEFAULT, SWT.DEFAULT);
      playing = false;
      delayDispose.offer(module.self);
    }
    module.dispose();
  }
 private static void showControl(boolean show, Control control) {
   Object data = control.getLayoutData();
   if (data instanceof GridData) {
     GridData gridData = (GridData) data;
     gridData.exclude = !show;
   }
   control.setVisible(show);
 }
 private void hideControl(Control control, boolean hide, boolean autoLayout) {
   control.setVisible(!hide);
   GridData layoutData = (GridData) control.getLayoutData();
   layoutData.exclude = hide;
   if (autoLayout) {
     control.getParent().layout();
   }
 }
 public static boolean hide(Composite section) {
   GridData data = (GridData) section.getLayoutData();
   if (data.exclude == false || data.heightHint != 0 || section.getVisible()) {
     data.heightHint = 0;
     data.exclude = true;
     section.setVisible(false);
     return true;
   }
   return false;
 }
 public static boolean show(Composite section) {
   GridData data = (GridData) section.getLayoutData();
   if (data.exclude == true || data.heightHint != -1 || !section.getVisible()) {
     data.heightHint = -1;
     data.exclude = false;
     section.setVisible(true);
     return true;
   }
   return false;
 }
 private void showControlGroup(String group, boolean show) {
   List<Control> controlList = propGroupMap.get(group);
   if (controlList != null) {
     for (Control control : controlList) {
       GridData gd = (GridData) control.getLayoutData();
       if (gd == null) {
         gd = new GridData(GridData.BEGINNING);
         control.setLayoutData(gd);
       }
       gd.exclude = !show;
       control.setVisible(show);
     }
   }
 }
  /**
   * Creates a new {@link LayoutActionBar} and adds it to the given parent.
   *
   * @param parent the parent composite to add the actions bar to
   * @param style the SWT style to apply
   * @param editor the associated layout editor
   */
  public LayoutActionBar(Composite parent, int style, GraphicalEditorPart editor) {
    super(parent, style | SWT.NO_FOCUS);
    mEditor = editor;

    GridLayout layout = new GridLayout(3, false);
    setLayout(layout);

    mLayoutToolBar = new ToolBar(this, /*SWT.WRAP |*/ SWT.FLAT | SWT.RIGHT | SWT.HORIZONTAL);
    mLayoutToolBar.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
    mZoomToolBar = createZoomControls();
    mZoomToolBar.setLayoutData(new GridData(SWT.END, SWT.BEGINNING, false, false));
    mLintToolBar = createLintControls();

    GridData lintData = new GridData(SWT.END, SWT.BEGINNING, false, false);
    lintData.exclude = true;
    mLintToolBar.setLayoutData(lintData);
  }
示例#14
0
  /** {@inheritDoc} */
  @Override
  public void maximizeSubView(ISubView subView) {
    ISubView maximizeSubView = subView;
    if (maximizeSubView == null) {
      maximizeSubView = getSubViews().get(0);
    }

    int[] weights = new int[getSubViews().size()];
    int i = 0;
    for (ISubView view : getSubViews()) {
      if (ObjectUtils.equals(view, maximizeSubView)) {
        view.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        weights[i] = 1;
      } else {
        GridData gd = new GridData();
        gd.exclude = true;
        view.getControl().setLayoutData(gd);
        weights[i] = 0;
      }
      i++;
    }
    sashForm.setWeights(weights);
    layout();
  }
示例#15
0
 private void addExcludedGridData(Composite facade) {
   GridData gridData = new GridData();
   gridData.exclude = true;
   facade.setLayoutData(gridData);
 }
 private void setControlVisible(Control control, boolean visible) {
   GridData data = (GridData) control.getLayoutData();
   data.exclude = !visible;
   control.setVisible(visible);
 }
示例#17
0
  public void layoutWidget(
      Control control,
      String elementName,
      Map<String, String> attributes,
      Composite composite,
      SwtMetawidget metawidget) {

    // Do not layout space for empty stubs

    if (control instanceof Stub && ((Stub) control).getChildren().length == 0) {
      GridData stubData = new GridData();
      stubData.exclude = true;
      control.setLayoutData(stubData);
      return;
    }

    // Special support for large controls (make the previous control span all and kick us to the
    // next row)

    boolean spanAllColumns = willFillHorizontally(control, attributes);

    if (spanAllColumns) {
      int totalHorizontalSpan = getTotalHorizontalSpan(composite);
      int numberColumnsRemainingOnRow =
          totalHorizontalSpan % (mNumberOfColumns * LABEL_AND_CONTROL);

      if (numberColumnsRemainingOnRow != 0) {
        Control lastControl = getLastNonExcludedControl(composite);
        ((GridData) lastControl.getLayoutData()).horizontalSpan = numberColumnsRemainingOnRow + 1;
      }
    }

    // Layout a label...

    String labelText = null;

    if (attributes != null) {
      labelText = metawidget.getLabelString(attributes);
    }

    layoutBeforeChild(control, labelText, elementName, attributes, composite, metawidget);

    // ...and layout the control

    GridData controlLayoutData = new GridData();
    controlLayoutData.grabExcessHorizontalSpace = true;

    if (!(control instanceof Button)) {
      controlLayoutData.horizontalAlignment = SWT.FILL;
      controlLayoutData.verticalAlignment = SWT.FILL;
    }

    if (spanAllColumns) {
      controlLayoutData.horizontalSpan = mNumberOfColumns * LABEL_AND_CONTROL;

      if (SimpleLayoutUtils.needsLabel(labelText, elementName)) {
        controlLayoutData.horizontalSpan--;
      }
    } else if (!SimpleLayoutUtils.needsLabel(labelText, elementName)) {
      controlLayoutData.horizontalSpan = LABEL_AND_CONTROL;
    }

    if (willFillVertically(control, attributes)) {
      controlLayoutData.grabExcessVerticalSpace = true;
    }

    // Add it

    control.setLayoutData(controlLayoutData);
  }
  void addControls(final Composite parent) {
    Label desc = new Label(parent, SWT.LEFT | SWT.WRAP);
    desc.setText("The Ceylon builder compiles Ceylon source contained in the project.");

    enableBuilderButton = new Button(parent, SWT.PUSH);
    enableBuilderButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
    enableBuilderButton.setText("Enable Ceylon Builder");
    enableBuilderButton.setEnabled(!builderEnabled && getSelectedProject().isOpen());
    enableBuilderButton.setImage(
        CeylonPlugin.getInstance().getImageRegistry().get(CeylonResources.ELE32));
    // enableBuilder.setSize(40, 40);

    Label sep = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
    GridData sgd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    sep.setLayoutData(sgd);

    Composite composite = new Composite(parent, SWT.NONE);
    GridData gdb = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gdb.grabExcessHorizontalSpace = true;
    composite.setLayoutData(gdb);
    GridLayout layoutb = new GridLayout();
    layoutb.numColumns = 1;
    layoutb.marginBottom = 1;
    composite.setLayout(layoutb);

    addCharacterEncodingLabel(composite);

    offlineButton = new Button(composite, SWT.CHECK);
    offlineButton.setText("Work offline (disable connection to remote module repositories)");
    offlineButton.setEnabled(builderEnabled);
    offlineButton.setSelection(offlineOption != null && offlineOption);
    offlineButton.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            if (offlineOption == null) {
              offlineOption = true;
            } else {
              offlineOption = !offlineOption;
            }
          }
        });

    final Group platformGroup = new Group(parent, SWT.NONE);
    platformGroup.setText("Target virtual machine");
    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd.grabExcessHorizontalSpace = true;
    platformGroup.setLayoutData(gd);
    GridLayout layout = new GridLayout();

    layout.numColumns = 1;
    layout.marginBottom = 1;
    platformGroup.setLayout(layout);

    compileToJava = new Button(platformGroup, SWT.CHECK);
    compileToJava.setText("Compile project for JVM");
    compileToJava.setSelection(backendJava);
    compileToJava.setEnabled(builderEnabled);

    compileToJs = new Button(platformGroup, SWT.CHECK);
    compileToJs.setText("Compile project to JavaScript");
    compileToJs.setSelection(backendJs);
    compileToJs.setEnabled(builderEnabled);

    Group troubleGroup = new Group(parent, SWT.NONE);
    troubleGroup.setText("Troubleshooting");
    troubleGroup.setLayout(new GridLayout(1, false));
    GridData gd3 = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd3.grabExcessHorizontalSpace = true;
    troubleGroup.setLayoutData(gd3);

    astAwareIncrementalBuidsButton = new Button(troubleGroup, SWT.CHECK);
    astAwareIncrementalBuidsButton.setText("Disable structure-aware incremental compilation");
    astAwareIncrementalBuidsButton.setSelection(!astAwareIncrementalBuids);
    astAwareIncrementalBuidsButton.setEnabled(builderEnabled);

    final Button logButton = new Button(troubleGroup, SWT.CHECK);
    logButton.setText("Log compiler activity to Eclipse console");
    boolean loggingEnabled = verbose != null && !verbose.isEmpty();
    logButton.setSelection(loggingEnabled);
    logButton.setEnabled(builderEnabled);

    final Composite verbosityOptions = new Composite(troubleGroup, SWT.NONE);
    verbosityOptions.setLayout(new GridLayout(2, false));
    final GridData gd4 = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd4.grabExcessHorizontalSpace = true;
    verbosityOptions.setLayoutData(gd4);
    gd4.exclude = !loggingEnabled;
    verbosityOptions.setVisible(loggingEnabled);
    verbosityOptions.setEnabled(loggingEnabled);

    final Label verbosityLabel = new Label(verbosityOptions, SWT.NONE);
    verbosityLabel.setText("Verbosity level");

    verboseText = new Combo(verbosityOptions, SWT.DROP_DOWN);
    verboseText.add("code");
    verboseText.add("ast");
    verboseText.add("loader");
    verboseText.add("cmr");
    verboseText.add("all");
    GridData vgd = new GridData();
    vgd.grabExcessHorizontalSpace = true;
    vgd.minimumWidth = 75;
    verboseText.setLayoutData(vgd);
    verboseText.setTextLimit(20);
    if (loggingEnabled) {
      verboseText.setText(verbose);
    }
    verboseText.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(ModifyEvent e) {
            String str = verboseText.getText();
            if (str == null || str.isEmpty()) {
              verbose = null;
            } else {
              verbose = str.trim();
            }
          }
        });

    logButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            boolean selected = logButton.getSelection();
            verbose = selected ? verboseText.getText() : null;
            verboseText.setEnabled(selected);
            ((GridData) verbosityOptions.getLayoutData()).exclude = !selected;
            verbosityOptions.setVisible(selected);
            verbosityOptions.setEnabled(selected);
            verboseText.setVisible(selected);
            parent.layout();
          }
        });

    enableBuilderButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            new CeylonNature().addToProject(getSelectedProject());
            enableBuilderButton.setEnabled(false);
            astAwareIncrementalBuidsButton.setEnabled(true);
            compileToJs.setEnabled(true);
            compileToJava.setEnabled(true);
            offlineButton.setEnabled(true);
            logButton.setEnabled(true);
            builderEnabled = true;
          }
        });

    astAwareIncrementalBuidsButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            astAwareIncrementalBuids = !astAwareIncrementalBuids;
          }
        });

    compileToJava.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            backendJava = !backendJava;
          }
        });

    compileToJs.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            backendJs = !backendJs;
          }
        });

    Link buildPathsPageLink = new Link(parent, 0);
    buildPathsPageLink.setText("See '<a>Build Paths</a>' to configure project build paths.");
    buildPathsPageLink.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            IWorkbenchPreferenceContainer container =
                (IWorkbenchPreferenceContainer) getContainer();
            container.openPage(CeylonBuildPathsPropertiesPage.ID, null);
          }
        });

    Link openRepoPageLink = new Link(parent, 0);
    openRepoPageLink.setText(
        "See '<a>Module Repositories</a>' to configure project module repositores.");
    openRepoPageLink.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            IWorkbenchPreferenceContainer container =
                (IWorkbenchPreferenceContainer) getContainer();
            container.openPage(CeylonRepoPropertiesPage.ID, null);
          }
        });

    Link warningsPageLink = new Link(parent, 0);
    warningsPageLink.setText("See '<a>Warnings</a>' to enable or disable warnings.");
    warningsPageLink.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            IWorkbenchPreferenceContainer container =
                (IWorkbenchPreferenceContainer) getContainer();
            container.openPage(CeylonWarningsPropertiesPage.ID, null);
          }
        });
  }
示例#19
0
 private void initGUI() {
   try {
     GridLayout thisLayout = new GridLayout();
     thisLayout.makeColumnsEqualWidth = true;
     this.setLayout(thisLayout);
     this.setSize(525, 237);
     group1 = new Group(this, SWT.NONE);
     GridLayout group1Layout = new GridLayout();
     group1Layout.makeColumnsEqualWidth = true;
     group1Layout.numColumns = 2;
     group1.setLayout(group1Layout);
     GridData group1LData = new GridData();
     group1LData.grabExcessHorizontalSpace = true;
     group1LData.horizontalAlignment = GridData.FILL;
     // group1LData.heightHint = 9;
     group1.setLayoutData(group1LData);
     group1.setText(Messages.FreqAnalysisUI_usagedescisionlabel);
     button1 = new Button(group1, SWT.RADIO | SWT.LEFT);
     GridData button1LData = new GridData();
     button1LData.grabExcessHorizontalSpace = true;
     button1LData.horizontalAlignment = GridData.FILL;
     button1.setLayoutData(button1LData);
     button1.setText(Messages.FreqAnalysisUI_descision1label);
     button1.addSelectionListener(
         new SelectionAdapter() {
           public void widgetSelected(SelectionEvent evt) {
             switchComposites(evt);
           }
         });
     button1.setSelection(false);
     button2 = new Button(group1, SWT.RADIO | SWT.LEFT);
     GridData button2LData = new GridData();
     button2LData.grabExcessHorizontalSpace = true;
     button2LData.horizontalAlignment = GridData.FILL;
     button2.setLayoutData(button2LData);
     button2.setText(Messages.FreqAnalysisUI_descision2label);
     button2.addSelectionListener(
         new SelectionAdapter() {
           public void widgetSelected(SelectionEvent evt) {
             switchComposites(evt);
           }
         });
     button2.setSelection(false);
     fakebtn = new Button(group1, SWT.RADIO | SWT.LEFT);
     fakebtn.setText("button3"); // $NON-NLS-1$
     GridData fakebtnLData = new GridData();
     fakebtnLData.exclude = true;
     fakebtn.setLayoutData(fakebtnLData);
     fakebtn.setSelection(true);
     C1 = new SimpleAnalysisUI(this, SWT.NONE);
     GridLayout C1Layout = new GridLayout();
     C1Layout.makeColumnsEqualWidth = true;
     GridData C1LData = new GridData();
     C1LData.grabExcessHorizontalSpace = true;
     C1LData.grabExcessVerticalSpace = true;
     C1LData.horizontalAlignment = GridData.FILL;
     C1LData.verticalAlignment = GridData.FILL;
     C1LData.exclude = true;
     C1.setLayoutData(C1LData);
     C1.setLayout(C1Layout);
     C1.setVisible(false);
     C2 = new FullAnalysisUI(this, SWT.NONE);
     GridLayout C2Layout = new GridLayout();
     C2Layout.makeColumnsEqualWidth = true;
     GridData C2LData = new GridData();
     C2LData.grabExcessHorizontalSpace = true;
     C2LData.grabExcessVerticalSpace = true;
     C2LData.verticalAlignment = GridData.FILL;
     C2LData.horizontalAlignment = GridData.FILL;
     C2LData.exclude = true;
     C2.setLayoutData(C2LData);
     C2.setLayout(C2Layout);
     C2.setVisible(false);
     this.layout();
   } catch (Exception e) {
     LogUtil.logError(FreqAnalysisPlugin.PLUGIN_ID, e);
   }
 }
示例#20
0
  private void checkPage() {
    boolean createBranchSelected = createBranch.getSelection();
    branchText.setEnabled(createBranchSelected);
    branchText.setVisible(createBranchSelected);
    branchTextlabel.setVisible(createBranchSelected);
    GridData gd = (GridData) branchText.getLayoutData();
    gd.exclude = !createBranchSelected;
    gd = (GridData) branchTextlabel.getLayoutData();
    gd.exclude = !createBranchSelected;

    boolean createTagSelected = createTag.getSelection();
    tagText.setEnabled(createTagSelected);
    tagText.setVisible(createTagSelected);
    tagTextlabel.setVisible(createTagSelected);
    gd = (GridData) tagText.getLayoutData();
    gd.exclude = !createTagSelected;
    gd = (GridData) tagTextlabel.getLayoutData();
    gd.exclude = !createTagSelected;
    branchText.getParent().layout(true);

    boolean showActivateAdditionalRefs = false;
    showActivateAdditionalRefs =
        (checkout.getSelection() || dontCheckout.getSelection())
            && !Activator.getDefault()
                .getPreferenceStore()
                .getBoolean(UIPreferences.RESOURCEHISTORY_SHOW_ADDITIONAL_REFS);

    gd = (GridData) warningAdditionalRefNotActive.getLayoutData();
    gd.exclude = !showActivateAdditionalRefs;
    warningAdditionalRefNotActive.setVisible(showActivateAdditionalRefs);
    warningAdditionalRefNotActive.getParent().layout(true);

    setErrorMessage(null);
    try {
      if (refText.getText().length() > 0) {
        Change change = Change.fromRef(refText.getText());
        if (change == null) {
          setErrorMessage(UIText.FetchGerritChangePage_MissingChangeMessage);
          return;
        }
      } else {
        setErrorMessage(UIText.FetchGerritChangePage_MissingChangeMessage);
        return;
      }

      boolean emptyRefName =
          (createBranchSelected && branchText.getText().length() == 0)
              || (createTagSelected && tagText.getText().length() == 0);
      if (emptyRefName) {
        setErrorMessage(UIText.FetchGerritChangePage_ProvideRefNameMessage);
        return;
      }

      boolean existingRefName =
          (createBranchSelected && repository.getRef(branchText.getText()) != null)
              || (createTagSelected && repository.getRef(tagText.getText()) != null);
      if (existingRefName) {
        setErrorMessage(
            NLS.bind(UIText.FetchGerritChangePage_ExistingRefMessage, branchText.getText()));
        return;
      }
    } catch (IOException e1) {
      // ignore here
    } finally {
      setPageComplete(getErrorMessage() == null);
    }
  }
 public void setVisible(boolean visible) {
   super.setVisible(visible);
   button.setVisible(visible);
   GridData data = (GridData) button.getLayoutData();
   data.exclude = !visible;
 }
  /**
   * Sets whether the action bar should show the "lint warnings" button
   *
   * @param hasLintWarnings whether there are lint errors to be shown
   */
  private void updateErrorIndicator(final int markerCount) {
    Display display = getDisplay();
    if (display.getThread() != Thread.currentThread()) {
      display.asyncExec(
          new Runnable() {
            @Override
            public void run() {
              if (!isDisposed()) {
                updateErrorIndicator(markerCount);
              }
            }
          });
      return;
    }

    GridData layoutData = (GridData) mLintToolBar.getLayoutData();
    Integer existing = (Integer) mLintToolBar.getData();
    Integer current = Integer.valueOf(markerCount);
    if (!current.equals(existing)) {
      mLintToolBar.setData(current);
      boolean layout = false;
      boolean hasLintWarnings = markerCount > 0 && AdtPrefs.getPrefs().isLintOnSave();
      if (layoutData.exclude == hasLintWarnings) {
        layoutData.exclude = !hasLintWarnings;
        mLintToolBar.setVisible(hasLintWarnings);
        layout = true;
      }
      if (markerCount > 0) {
        String iconName = "";
        switch (markerCount) {
          case 1:
            iconName = "lint1";
            break; //$NON-NLS-1$
          case 2:
            iconName = "lint2";
            break; //$NON-NLS-1$
          case 3:
            iconName = "lint3";
            break; //$NON-NLS-1$
          case 4:
            iconName = "lint4";
            break; //$NON-NLS-1$
          case 5:
            iconName = "lint5";
            break; //$NON-NLS-1$
          case 6:
            iconName = "lint6";
            break; //$NON-NLS-1$
          case 7:
            iconName = "lint7";
            break; //$NON-NLS-1$
          case 8:
            iconName = "lint8";
            break; //$NON-NLS-1$
          case 9:
            iconName = "lint9";
            break; //$NON-NLS-1$
          default:
            iconName = "lint9p";
            break; //$NON-NLS-1$
        }
        mLintButton.setImage(IconFactory.getInstance().getIcon(iconName));
      }
      if (layout) {
        layout();
      }
      redraw();
    }
  }
  @Override
  protected void createTreeTextOptions(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(3, false);
    layout.horizontalSpacing = 0;
    layout.marginHeight = 0;
    layout.verticalSpacing = 0;
    composite.setLayout(layout);

    radioWaybill = new Button(composite, SWT.RADIO);
    radioWaybill.setText(Messages.SpecimenTransitView_waybill_label);
    radioWaybill.setSelection(true);
    radioWaybill.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (radioWaybill.getSelection()) {
              showTextOnly(true);
            }
          }
        });

    radioDateReceived = new Button(composite, SWT.RADIO);
    radioDateReceived.setText(Messages.SpecimenTransitView_received_label);
    radioDateReceived.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (radioDateReceived.getSelection()) {
              showTextOnly(false);
            }
          }
        });

    radioDateSent = new Button(composite, SWT.RADIO);
    radioDateSent.setText(Messages.SpecimenTransitView_packed_label);
    radioDateSent.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (radioDateSent.getSelection()) {
              showTextOnly(false);
            }
          }
        });

    dateComposite = new Composite(parent, SWT.NONE);
    layout = new GridLayout(2, false);
    layout.horizontalSpacing = 0;
    layout.marginHeight = 0;
    layout.verticalSpacing = 0;
    dateComposite.setLayout(layout);
    GridData gd = new GridData();
    gd.exclude = true;
    dateComposite.setLayoutData(gd);

    dateWidget = new DateTimeWidget(dateComposite, SWT.DATE, new Date());
    dateWidget.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetDefaultSelected(SelectionEvent e) {
            internalSearch();
          }
        });
    Button searchButton = new Button(dateComposite, SWT.PUSH);
    searchButton.setText(Messages.SpecimenTransitView_go_label);
    searchButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            internalSearch();
          }
        });
  }
示例#24
0
  protected void updateControls() {
    setMessage(null);
    setErrorMessage(null);
    if (!internalMode) {
      setDescription(UIText.ExistingOrNewPage_DescriptionExternalMode);
      if (this.selectedRepository != null) {
        workDir.setText(this.selectedRepository.getWorkTree().getPath());
        String relativePath = relPath.getText();
        File testFile = new File(this.selectedRepository.getWorkTree(), relativePath);
        if (!testFile.exists())
          setMessage(
              NLS.bind(UIText.ExistingOrNewPage_FolderWillBeCreatedMessage, relativePath),
              IMessageProvider.WARNING);
        IPath targetPath = new Path(selectedRepository.getWorkTree().getPath());
        targetPath = targetPath.append(relPath.getText());
        moveProjectsLabelProvider.targetFolder = targetPath;
        projectMoveViewer.refresh(true);
        browseRepository.setEnabled(true);
        for (Object checked : projectMoveViewer.getCheckedElements()) {
          IProject prj = (IProject) checked;
          IPath projectMoveTarget = targetPath.append(prj.getName());
          boolean mustMove = !prj.getLocation().equals(projectMoveTarget);
          File targetTest = new File(projectMoveTarget.toOSString());
          if (mustMove && targetTest.exists()) {
            setErrorMessage(
                NLS.bind(UIText.ExistingOrNewPage_ExistingTargetErrorMessage, prj.getName()));
            break;
          }
          File parent = targetTest.getParentFile();
          while (parent != null) {
            if (new File(parent, ".project").exists()) { // $NON-NLS-1$
              setErrorMessage(
                  NLS.bind(
                      UIText.ExistingOrNewPage_NestedProjectErrorMessage,
                      new String[] {prj.getName(), targetTest.getPath(), parent.getPath()}));
              break;
            }
            parent = parent.getParentFile();
          }
          // break after the first error
          if (getErrorMessage() != null) break;
        }
      } else workDir.setText(UIText.ExistingOrNewPage_NoRepositorySelectedMessage);
      setPageComplete(
          getErrorMessage() == null
              && selectedRepository != null
              && projectMoveViewer.getCheckedElements().length > 0);
    } else {
      setDescription(UIText.ExistingOrNewPage_description);
      IPath p = proposeNewRepositoryPath(tree.getSelection());
      minumumPath = p;
      if (p != null) {
        repositoryToCreate.setText(p.toOSString());
      } else {
        repositoryToCreate.setText(""); // $NON-NLS-1$
      }
      createRepo.setEnabled(p != null);
      repositoryToCreate.setEnabled(p != null);
      dotGitSegment.setEnabled(p != null);

      boolean pageComplete = viewer.getCheckedElements().length > 0;
      for (Object checkedElement : viewer.getCheckedElements()) {
        String path = ((ProjectAndRepo) checkedElement).getRepo();
        if (((ProjectAndRepo) checkedElement).getRepo() != null && path.equals("")) { // $NON-NLS-1$
          pageComplete = false;
        }
      }
      setPageComplete(pageComplete);
      // provide a warning if Repository is created in workspace
      for (IProject project : myWizard.projects) {
        if (createRepo.isEnabled()
            && ResourcesPlugin.getWorkspace()
                .getRoot()
                .getLocation()
                .isPrefixOf(project.getLocation())) {
          setMessage(
              UIText.ExistingOrNewPage_RepoCreationInWorkspaceCreationWarning,
              IMessageProvider.WARNING);
          break;
        }
      }
    }

    externalComposite.setVisible(!internalMode);
    parentRepoComposite.setVisible(internalMode);
    GridData gd;
    gd = (GridData) parentRepoComposite.getLayoutData();
    gd.exclude = !internalMode;

    gd = (GridData) externalComposite.getLayoutData();
    gd.exclude = internalMode;

    ((Composite) getControl()).layout(true);
  }