protected void makeStartCommandControlsVisible(StartCommandType typeToMakeVisible) {
    StartCommandPart part = startCommandAreas.get(typeToMakeVisible);
    Control areaToMakeVisible = part != null ? part.getComposite() : null;

    if (areaToMakeVisible != null && !areaToMakeVisible.isDisposed()) {

      GridData data = (GridData) areaToMakeVisible.getLayoutData();
      GridDataFactory.createFrom(data).exclude(false).applyTo(areaToMakeVisible);
      areaToMakeVisible.setVisible(true);

      // Hide the other sections
      // If hiding, exclude from layout as to not take up space when it is
      // made invisible
      for (StartCommandType otherTypes : startCommandAreas.keySet()) {
        if (!otherTypes.equals(typeToMakeVisible)) {
          StartCommandPart otherArea = startCommandAreas.get(otherTypes);

          if (otherArea != null) {
            Control otherAreaComposite = otherArea.getComposite();

            if (!otherAreaComposite.isDisposed()) {
              data = (GridData) otherAreaComposite.getLayoutData();
              GridDataFactory.createFrom(data).exclude(true).applyTo(otherAreaComposite);

              otherAreaComposite.setVisible(false);
            }
          }
        }
      }

      // Recalculate layout
      areaToMakeVisible.getParent().layout(true, true);
    }
  }
Exemple #2
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);
 }
 private void updateVisible() {
   Iterator iter = controls.iterator();
   while (iter.hasNext()) {
     Control control = (Control) iter.next();
     control.setVisible(visible);
   }
 }
  private void loadViewPanesVisibility() {
    String visiblePanes =
        Platform.getPreferencesService()
            .getString(DebugUIPlugin.getUniqueIdentifier(), getVisibilityPrefId(), null, null);

    if (visiblePanes != null && visiblePanes.length() > 0) {
      StringTokenizer tokenizer = new StringTokenizer(visiblePanes, ","); // $NON-NLS-1$
      while (tokenizer.hasMoreTokens()) {
        String paneId = tokenizer.nextToken();
        fVisibleViewPanes.add(paneId);
      }
    } else {
      for (int i = 0; i < defaultVisiblePaneIds.length; i++) {
        fVisibleViewPanes.add(defaultVisiblePaneIds[i]);
      }
    }

    Enumeration<String> enumeration = fViewPaneControls.keys();
    while (enumeration.hasMoreElements()) {
      String paneId = enumeration.nextElement();
      boolean visible = false;
      if (fVisibleViewPanes.contains(paneId)) visible = true;

      Control control = fViewPaneControls.get(paneId);
      control.setVisible(visible);

      IMemoryViewPane viewPane = fViewPanes.get(paneId);
      viewPane.setVisible(visible);
    }

    fSashForm.layout();
  }
 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 void deactivate() {
   if (activeEditor != null) {
     Control control = activeEditor.getControl();
     if (control != null && !control.isDisposed()) {
       control.setVisible(false);
     }
   }
 }
 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);
 }
  protected Composite createFilterControls(Composite parent) {
    createSearchTextNew(parent);
    createFilterText(parent);
    createClearTextNew(parent);
    if (clearButtonControl != null) {
      // initially there is no text to clear
      clearButtonControl.setVisible(false);
    }

    return parent;
  }
Exemple #9
0
  /**
   * Sets the visibility of a control. Includes setting of the include property of the layoutData
   * (if available)
   *
   * @param visible
   */
  public static void setVisiblity(Control control, boolean visible) {
    if (control == null) {
      return;
    }

    control.setVisible(visible);
    Object layoutData = control.getLayoutData();
    if (layoutData instanceof GridData) {
      ((GridData) layoutData).exclude = !visible;
    }
  }
 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);
     }
   }
 }
 @Override
 protected Control createHelpControl(Composite parent) {
   helpControl = super.createHelpControl(parent);
   ToolItem item = ((ToolBar) helpControl).getItem(0);
   Listener[] listeners = item.getListeners(SWT.Selection);
   if (listeners.length > 0) {
     for (Listener l : listeners) {
       item.removeListener(SWT.Selection, l);
     }
   }
   item.addListener(SWT.Selection, openTrayListener);
   if (currentExpressionEditor != null) {
     //			helpControl.setVisible(currentExpressionEditor.provideDialogTray());
     helpControl.setVisible(false);
   }
   return helpControl;
 }
Exemple #12
0
  @Override
  public void createPartControl(Composite parent) {
    Control[] childern = parent.getChildren();
    for (Control control : childern) {
      control.setVisible(false);
    }
    form = new SashForm(parent, 512);
    form.setLayout(new FillLayout());
    folder = new TabFolder(form, 128);
    // theConjectures = new ValidationTable(form, this);
    // form.setWeights(new int[] { 85, 15 });
    theArch = new GenericTabItem("Architecture overview", folder, AllowedOverrunDirection.Both);
    theOverview =
        new GenericTabItem("Execution overview", folder, AllowedOverrunDirection.Vertical);
    cw.clear();
    IFile file = null;
    try {

      file = ((FileEditorInput) getEditorInput()).getFile();

      FileUtility.deleteMarker(file, null, TracefileViewerPlugin.PLUGIN_ID);

      theMarkers = new TracefileMarker(file);

      if (FileUtility.getContent(file).size() == 0) {
        ErrorDialog.openError(
            getSite().getShell(), "Editor open", "File is empty", Status.CANCEL_STATUS);
        return;
      }

    } catch (Exception e) {
      TracefileViewerPlugin.log(e);
    } catch (OutOfMemoryError m) {
      showMessage(
          "The trace file can not be visualized because the Java Virtual Machine ran out of heap space. Try to allow Overture more heap space using Virtual Machine custom arguments (e.g. -Xms40m -Xmx512m).");
      return;
    }

    try {
      parseFile(selectedFile.getAbsolutePath());
    } catch (Exception e) {
      TracefileViewerPlugin.log(e);
    }
    openValidationConjectures(file);
  }
Exemple #13
0
  /**
   * Sets the control whose position will be managed by this proxy
   *
   * @param target the control, or null if none
   */
  public void setTargetControl(Control target) {
    if (this.target != target) {

      if (this.target != null) {
        for (Control next = control;
            next != commonAncestor && next != null;
            next = next.getParent()) {
          next.removeControlListener(controlListener);
        }
        commonAncestor = null;

        // If we already had a target, detach the dispose listener
        // (prevents memory leaks due to listeners)
        if (!this.target.isDisposed()) {
          this.target.removeDisposeListener(disposeListener);
        }
      }

      if (this.target == null && target != null) {
        // If we had previously forced the dummy control invisible, restore its visibility
        control.setVisible(visible);
      }

      this.target = target;

      if (target != null) {
        commonAncestor = SwtUtil.findCommonAncestor(this.target, control);
        for (Control next = control;
            next != null && next != commonAncestor;
            next = next.getParent()) {
          next.addControlListener(controlListener);
        }

        // Make the new target's visiblity match the visibility of the dummy control
        target.setVisible(control.getVisible());
        // Add a dispose listener. Ensures that the target is cleared
        // if it is ever disposed.
        target.addDisposeListener(disposeListener);
      } else {
        control.setVisible(false);
      }
    }
  }
  private void switchViewer(int state) {
    // Indicate which viewer is to be used
    if (fCurrViewState == state) return;
    else {
      fCurrViewState = state;
      IPreferenceStore store = DLTKUIPlugin.getDefault().getPreferenceStore();
      store.setValue(getViewSite().getId() + TAG_VIEW_STATE, state);
    }

    // get the information from the existing viewer
    StructuredViewer viewer = fWrappedViewer.getViewer();
    Object object = viewer.getInput();
    ISelection selection = viewer.getSelection();

    // create and set up the new viewer
    Control control = createViewer(fWrappedViewer.getControl().getParent()).getControl();

    setUpViewer(fWrappedViewer);

    createSelectAllAction();

    // add the selection information from old viewer
    fWrappedViewer.setViewerInput(object);
    fWrappedViewer.getControl().setFocus();
    fWrappedViewer.setSelection(selection, true);

    // dispose old viewer
    viewer.getContentProvider().dispose();
    viewer.getControl().dispose();

    // layout the new viewer
    if (control != null && !control.isDisposed()) {
      control.setVisible(true);
      control.getParent().layout(true);
    }
  }
 private void setVisible(Control control, boolean visible) {
   if (control != null && !control.isDisposed()) {
     control.setVisible(visible);
   }
 }
Exemple #16
0
 public void handleEvent(Event event) {
   if (target != null) {
     visible = control.getVisible();
     target.setVisible(visible);
   }
 }
 private void setControlVisible(Control control, boolean visible) {
   GridData data = (GridData) control.getLayoutData();
   data.exclude = !visible;
   control.setVisible(visible);
 }
  public Object safeCreateGui(
      MUIElement element, Object parentWidget, IEclipseContext parentContext) {
    if (!element.isToBeRendered()) return null;

    if (!renderedElements.contains(element)) renderedElements.add(element);

    // no creates while processing a remove
    if (removeRoot != null) {
      return null;
    }

    Object currentWidget = element.getWidget();
    if (currentWidget != null) {
      if (currentWidget instanceof Control) {
        Control control = (Control) currentWidget;
        // make sure the control is visible
        control.setVisible(true);

        if (parentWidget instanceof Composite) {
          Composite currentParent = control.getParent();
          if (currentParent != parentWidget) {
            // check if the original parent was a tab folder
            if (currentParent instanceof CTabFolder) {
              CTabFolder folder = (CTabFolder) currentParent;
              // if we used to be the tab folder's top right
              // control, unset it
              if (folder.getTopRight() == control) {
                folder.setTopRight(null);
              }
            }

            // the parents are different so we should reparent it
            control.setParent((Composite) parentWidget);
          }
        }
      }

      // Reparent the context (or the kid's context)
      if (element instanceof MContext) {
        IEclipseContext ctxt = ((MContext) element).getContext();
        if (ctxt != null) ctxt.setParent(parentContext);
      } else {
        List<MContext> childContexts =
            modelService.findElements(element, null, MContext.class, null);
        for (MContext c : childContexts) {
          // Ensure that we only reset the context of our direct
          // children
          MUIElement kid = (MUIElement) c;
          MUIElement parent = kid.getParent();
          if (parent == null && kid.getCurSharedRef() != null)
            parent = kid.getCurSharedRef().getParent();
          if (!(element instanceof MPlaceholder) && parent != element) continue;

          if (c.getContext() != null && c.getContext().getParent() != parentContext) {
            c.getContext().setParent(parentContext);
          }
        }
      }

      // Now that we have a widget let the parent (if any) know
      if (element.getParent() instanceof MUIElement) {
        MElementContainer<MUIElement> parentElement = element.getParent();
        AbstractPartRenderer parentRenderer = getRendererFor(parentElement);
        if (parentRenderer != null) parentRenderer.childRendered(parentElement, element);
      }
      return element.getWidget();
    }

    if (element instanceof MContext) {
      MContext ctxt = (MContext) element;
      // Assert.isTrue(ctxt.getContext() == null,
      // "Before rendering Context should be null");
      if (ctxt.getContext() == null) {
        IEclipseContext lclContext = parentContext.createChild(getContextName(element));
        populateModelInterfaces(ctxt, lclContext, element.getClass().getInterfaces());
        ctxt.setContext(lclContext);

        // System.out.println("New Context: " + lclContext.toString()
        // + " parent: " + parentContext.toString());

        // make sure the context knows about these variables that have
        // been defined in the model
        for (String variable : ctxt.getVariables()) {
          lclContext.declareModifiable(variable);
        }

        Map<String, String> props = ctxt.getProperties();
        for (String key : props.keySet()) {
          lclContext.set(key, props.get(key));
        }

        E4Workbench.processHierarchy(element);
      }
    }

    // Create a control appropriate to the part
    Object newWidget = createWidget(element, parentWidget);

    // Remember that we've created the control
    if (newWidget != null) {
      AbstractPartRenderer renderer = getRendererFor(element);

      // Have the renderer hook up any widget specific listeners
      renderer.hookControllerLogic(element);

      // Process its internal structure through the renderer that created
      // it
      if (element instanceof MElementContainer) {
        renderer.processContents((MElementContainer<MUIElement>) element);
      }

      // Allow a final chance to set up
      renderer.postProcess(element);

      // Now that we have a widget let the parent (if any) know
      if (element.getParent() instanceof MUIElement) {
        MElementContainer<MUIElement> parentElement = element.getParent();
        AbstractPartRenderer parentRenderer = getRendererFor(parentElement);
        if (parentRenderer != null) parentRenderer.childRendered(parentElement, element);
      }
    } else {
      // failed to create the widget, dispose its context if necessary
      if (element instanceof MContext) {
        MContext ctxt = (MContext) element;
        IEclipseContext lclContext = ctxt.getContext();
        if (lclContext != null) {
          lclContext.dispose();
          ctxt.setContext(null);
        }
      }
    }

    return newWidget;
  }
 protected void updateToolbar(boolean visible) {
   if (clearButtonControl != null) {
     clearButtonControl.setVisible(visible);
   }
 }
Exemple #20
0
 /**
  * ウィジェットを非表示または表示します。
  *
  * @param widget
  * @param hide
  */
 public static void hide(Control widget, boolean hide) {
   widget.setVisible(!hide);
   recirsivelySetExclude(widget, hide);
 }
  protected void showContent(String type) {
    IExpressionProvider provider =
        ExpressionEditorService.getInstance().getExpressionProvider(type);

    Assert.isNotNull(provider);

    for (Control c : contentComposite.getChildren()) {
      c.dispose();
    }

    if (currentExpressionEditor != null) {
      currentExpressionEditor.dispose();
    }

    currentExpressionEditor = provider.getExpressionEditor(inputExpression, context);
    currentExpressionEditor.setIsPageFlowContext(isPageFlowContext);
    if (currentExpressionEditor != null) {
      currentExpressionEditor.createExpressionEditor(contentComposite, isPassword);
      contentComposite.layout(true, true);
      if (helpControl != null) {
        //				helpControl.setVisible(currentExpressionEditor.provideDialogTray());
        helpControl.setVisible(false);
        if (currentExpressionEditor.provideDialogTray()) {
          ToolItem item = ((ToolBar) helpControl).getItem(0);
          item.setSelection(true);
          openTrayListener.handleEvent(new Event());
        } else if (getTray() != null) {
          closeTray();
        }
      }
      if (dataBindingContext != null) {
        dataBindingContext.dispose();
      }
      dataBindingContext = new EMFDataBindingContext();

      UpdateValueStrategy selectionToExpressionType = new UpdateValueStrategy();
      IConverter convert =
          new Converter(IExpressionProvider.class, String.class) {

            @Override
            public Object convert(Object arg0) {
              return ((IExpressionProvider) arg0).getExpressionType();
            }
          };
      selectionToExpressionType.setConverter(convert);

      if (domain != null) {
        domain
            .getCommandStack()
            .execute(
                SetCommand.create(
                    domain, inputExpression, ExpressionPackage.Literals.EXPRESSION__TYPE, type));
      } else {
        inputExpression.setType(type);
      }
      currentExpressionEditor.bindExpression(
          dataBindingContext, context, inputExpression, viewerTypeFilters, expressionViewer);
      currentExpressionEditor.addListener(
          new Listener() {
            @Override
            public void handleEvent(Event event) {
              Button okButton = getButton(OK);
              if (okButton != null && !okButton.isDisposed()) {
                okButton.setEnabled(currentExpressionEditor.canFinish());
              }
            }
          });
      DialogSupport.create(this, dataBindingContext);
    }
  }