org.eclipse.swt.widgets.TreeItem#dispose ( )源码实例Demo

下面列出了org.eclipse.swt.widgets.TreeItem#dispose ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: nebula   文件: PTWidgetTree.java
/**
 * @see org.eclipse.nebula.widgets.opal.propertytable.AbstractPTWidget#refillData()
 */
@Override
public void refillData() {
	try {
		if (tree != null) {
			tree.setRedraw(false);
			for (final TreeItem treeItem : tree.getItems()) {
				treeItem.dispose();
			}
		}
		fillData();
	} finally {
		tree.setRedraw(true);
		tree.redraw();
		tree.update();
	}
}
 
源代码2 项目: RepDev   文件: MainShell.java
private void removeSym(TreeItem currentItem) {
	int sym;

	while (!(currentItem.getData() instanceof Integer)) {
		currentItem = currentItem.getParentItem();

		if (currentItem == null)
			return;
	}

	sym = (Integer) currentItem.getData();

	MessageBox dialog = new MessageBox(shell, SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
	dialog.setText("Confirm Sym Close");
	dialog.setMessage("Are you sure you want to close this Sym?");

	if (dialog.open() == SWT.OK) {
		ProjectManager.saveProjects(sym);
		RepDevMain.SYMITAR_SESSIONS.get(sym).disconnect();
		RepDevMain.SYMITAR_SESSIONS.remove(sym);

		currentItem.dispose();
	}

	tree.notifyListeners(SWT.Selection, null);
}
 
源代码3 项目: RepDev   文件: MainShell.java
private void removeProject(TreeItem cur) {
	while (cur != null && !(cur.getData() instanceof Project))
		cur = cur.getParentItem();

	if (cur == null)
		return;

	Project proj = (Project) cur.getData();
	RemProjShell.Result result = RemProjShell.confirm(display, shell, proj);

	if (result == RemProjShell.Result.OK_KEEP) {
		cur.dispose();
		ProjectManager.removeProject(proj, false);
	} else if (result == RemProjShell.Result.OK_DELETE) {
		cur.dispose();
		ProjectManager.removeProject(proj, true);
	}

	tree.notifyListeners(SWT.Selection, null);
}
 
源代码4 项目: RepDev   文件: MainShell.java
private void removeDir(TreeItem currentItem) {
	String dir;

	while (!(currentItem.getData() instanceof String)) {
		currentItem = currentItem.getParentItem();

		if (currentItem == null)
			return;
	}

	dir = (String) currentItem.getData();

	MessageBox dialog = new MessageBox(shell, SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
	dialog.setText("Confirm Directory Close");
	dialog.setMessage("Are you sure you want to close this directory?");

	if (dialog.open() == SWT.OK) {
		ProjectManager.saveProjects(dir);
		Config.getMountedDirs().remove(dir);

		currentItem.dispose();
	}

	tree.notifyListeners(SWT.Selection, null);
}
 
源代码5 项目: uima-uimaj   文件: ResourcePickerDialog.java
@Override
public void handleEvent(Event event) {
  if (event.widget == resourcesUI &&
      event.type == SWT.Expand) {
    TreeItem expandedNode = (TreeItem) event.item;
    TreeItem maybeDummy = expandedNode.getItem(0);
    if (null == maybeDummy.getData()) {
      maybeDummy.dispose();
      IResource parentResource = (IResource)expandedNode.getData();
      try {
        populate(expandedNode, ((IContainer)parentResource).members());
      } catch (CoreException e) {
        throw new InternalErrorCDE("unhandled exception", e);
      }
    }
  } else if (event.widget == resourcesUI && event.type == SWT.Selection) {
    copyValuesFromGUI();
  }
  super.handleEvent(event);
}
 
源代码6 项目: uima-uimaj   文件: ParameterSection.java
/**
 * Removes the parameter.
 *
 * @param itemToRemove the item to remove
 * @param nameToRemove the name to remove
 */
private void removeParameter(TreeItem itemToRemove, String nameToRemove) {
  TreeItem parentItem = itemToRemove.getParentItem();
  ConfigurationGroup cg = null;
  String parentGroupName = getName(parentItem.getText());
  if (parentGroupName.equals(NOT_IN_ANY_GROUP))
    cpd.setConfigurationParameters(removeConfigurationParameter(cpd.getConfigurationParameters(),
            nameToRemove));
  else if (parentGroupName.equals(COMMON_GROUP))
    cpd.setCommonParameters(commonParms = removeConfigurationParameter(cpd.getCommonParameters(),
            nameToRemove));
  else {
    cg = getConfigurationGroup(parentGroupName);
    cg.setConfigurationParameters(removeConfigurationParameter(cg.getConfigurationParameters(),
            nameToRemove));

  }
  removeParmSettingFromMultipleGroups(itemToRemove, REMOVE_FROM_GUI);
  itemToRemove.dispose();

  if (null != cg && cg.getConfigurationParameters().length == 0) {
    removeGroup(parentItem, getName(parentItem));
  }
}
 
源代码7 项目: hop   文件: ScriptDialog.java
private void modifyScriptTree( CTabItem ctabitem, int iModType ) {

    switch ( iModType ) {
      case DELETE_ITEM:
        TreeItem dItem = getTreeItemByName( ctabitem.getText() );
        if ( dItem != null ) {
          dItem.dispose();
          input.setChanged();
        }
        break;
      case ADD_ITEM:
        TreeItem item = new TreeItem( wTreeScriptsItem, SWT.NULL );
        item.setImage( imageActiveScript );
        item.setText( ctabitem.getText() );
        input.setChanged();
        break;

      case RENAME_ITEM:
        input.setChanged();
        break;
      case SET_ACTIVE_ITEM:
        input.setChanged();
        break;
      default:
        break;
    }
  }
 
源代码8 项目: uima-uimaj   文件: ParameterSection.java
/**
 * Removes the group.
 *
 * @param itemToRemove the item to remove
 * @param nameToRemove the name to remove
 */
private void removeGroup(TreeItem itemToRemove, String nameToRemove) {
  if (nameToRemove.equals(COMMON_GROUP)) {
    removeCommonParmSettingsFromMultipleGroups();
    cpd.setCommonParameters(configurationParameterArray0);
    commonParms = configurationParameterArray0;
    // can't really remove the <Common> group so remove all the parms
    disposeAllChildItems(itemToRemove);

  } else if (nameToRemove.equals(NOT_IN_ANY_GROUP)) {
    // remove settings for all non-group parm definitions
    removeIncludedParmSettingsFromSingleGroup(NOT_IN_ANY_GROUP, null);
    cpd.setConfigurationParameters(configurationParameterArray0);
    // remove all non-group parm definitions
    disposeAllChildItems(itemToRemove);

  } else {
    ConfigurationGroup cg = getConfigurationGroup(nameToRemove);
    // remove settings for all parms in the group too
    // also updates the settings GUI if the GUI is initialized
    removeIncludedParmSettingsFromMultipleGroups(cg.getNames(), cg.getConfigurationParameters());

    // remove group
    cpd.setConfigurationGroups(removeConfigurationGroup(cpd.getConfigurationGroups(), cg));
    itemToRemove.dispose(); // also disposes children of group in
    // GUI
  }
}
 
源代码9 项目: hop   文件: UserDefinedJavaClassDialog.java
private void modifyTabTree( CTabItem ctabitem, TabActions action ) {

    switch ( action ) {
      case DELETE_ITEM:
        TreeItem dItem = getTreeItemByName( ctabitem.getText() );
        if ( dItem != null ) {
          dItem.dispose();
          input.setChanged();
        }
        break;
      case ADD_ITEM:
        TreeItem item = new TreeItem( wTreeClassesItem, SWT.NULL );
        item.setImage( imageActiveScript );
        item.setText( ctabitem.getText() );
        input.setChanged();
        break;

      case RENAME_ITEM:
        input.setChanged();
        break;
      case SET_ACTIVE_ITEM:
        input.setChanged();
        break;
      default:
        break;
    }
  }
 
源代码10 项目: birt   文件: ExpressionTreeSupport.java
private void clearTreeItem( TreeItem treeItem )
{
	if ( treeItem == null || treeItem.isDisposed( ) )
	{
		return;
	}
	treeItem.dispose( );
}
 
源代码11 项目: RepDev   文件: MainShell.java
private int removeFile(TreeItem cur, int lastResult) {
	if (!(cur.getData() instanceof SymitarFile))
		return 0;

	SymitarFile file = (SymitarFile) cur.getData();
	Project proj = (Project) cur.getParentItem().getData();
	int result = lastResult;

	if ((lastResult & RemFileShell.REPEAT) == 0)
		result = RemFileShell.confirm(display, shell, proj, file);

	if ((result & RemFileShell.OK) > 0 && (result & RemFileShell.DELETE) == 0) {
		proj.removeFile(file, false);
		cur.dispose();
	} else if ((result & RemFileShell.OK) > 0 && (result & RemFileShell.DELETE) > 0) {
		proj.removeFile(file, true);
		cur.dispose();
	}

	if (!proj.isLocal())
		ProjectManager.saveProjects(proj.getSym());
	else
		ProjectManager.saveProjects(proj.getDir());

	tree.notifyListeners(SWT.Selection, null);
	for (CTabItem c : mainfolder.getItems()) {
		if (c.getData("file") != null && c.getData("file").equals(file)) {
			c.dispose();
		}
	}
	return result;
}
 
源代码12 项目: uima-uimaj   文件: ExtnlResBindSection.java
/**
 * Removes the binding.
 *
 * @param item the item
 */
private void removeBinding(TreeItem item) {
  ExternalResourceBinding xrb = getXRBindingFromTreeItem(item);
  getResourceManagerConfiguration().removeExternalResourceBinding(xrb);
  removeBoundFlagInDependencySection(xrb);
  item.dispose();
  setFileDirty();
}
 
源代码13 项目: uima-uimaj   文件: AbstractSectionParm.java
/**
 * Removes the included parm settings from single group.
 *
 * @param groupName the group name
 * @param cps          in ParameterSection of items an array of tree items to remove Can be all items under a
 *          particular group, or a set of items from different groups
 */
public void removeIncludedParmSettingsFromSingleGroup(String groupName,
        ConfigurationParameter[] cps) {
  ConfigurationParameterSettings modelSettings = getModelSettings();
  // modelSettings.setParameterValue()
  if (groupName.equals(COMMON_GROUP))
    throw new InternalErrorCDE("invalid state"); //$NON-NLS-1$

  if (groupName.equals(NOT_IN_ANY_GROUP)) {
    modelSettings.setParameterSettings(nameValuePairArray0);

  } else {
    for (int i = 0; i < cps.length; i++)
      modelSettings.setParameterValue(groupName, cps[i].getName(), null);
  }
  if (null != settings) {
    TreeItem settingGroup = getSettingsGroupTreeItemByName(groupName);
    if (groupName.equals(COMMON_GROUP) || groupName.equals(NOT_IN_ANY_GROUP)) {
      disposeAllChildItems(settingGroup);
    } else {
      if (getConfigurationParameterDeclarations().getConfigurationGroupDeclarations(groupName).length == 1) {
        settingGroup.dispose();
      } else {

        for (int i = 0; i < cps.length; i++) {
          findMatchingParm(settingGroup, cps[i].getName()).dispose();
        }
      }

    }
  }
}
 
源代码14 项目: uima-uimaj   文件: AbstractSection.java
/**
 * Swap tree items.
 *
 * @param itemBelow the item below
 * @param newSelection the new selection
 */
public static void swapTreeItems(TreeItem itemBelow, int newSelection) {
  TreeItem parent = itemBelow.getParentItem();
  if (null == parent)
    throw new InternalErrorCDE("invalid arg");
  int i = getIndex(itemBelow);
  TreeItem itemAbove = parent.getItems()[i - 1];
  TreeItem newItemAbove = new TreeItem(parent, SWT.NONE, i - 1);
  copyTreeItem(newItemAbove, itemBelow);
  TreeItem newItemBelow = new TreeItem(parent, SWT.NONE, i);
  copyTreeItem(newItemBelow, itemAbove);
  itemAbove.dispose();
  itemBelow.dispose();
  parent.getParent().setSelection(new TreeItem[] { parent.getItems()[newSelection] });
}
 
源代码15 项目: uima-uimaj   文件: CapabilitySection.java
/**
 * Removes the all feat item gui.
 *
 * @param editItem the edit item
 * @param column the column
 */
private void removeAllFeatItemGui(TreeItem editItem, int column) {
  TreeItem allFeatItem = getAllFeatItem(editItem);
  if (null == allFeatItem)
    // throw new InternalErrorCDE("invalid state");
    return; // happens when no allfeat is set
  allFeatItem.setText(column, "");
  String otherCol = allFeatItem.getText((column == INPUT_COL) ? OUTPUT_COL : INPUT_COL);
  if (null == otherCol || "".equals(otherCol))
    allFeatItem.dispose();
}
 
源代码16 项目: pentaho-kettle   文件: ScriptDialog.java
private void modifyScriptTree( CTabItem ctabitem, int iModType ) {

    switch ( iModType ) {
      case DELETE_ITEM:
        TreeItem dItem = getTreeItemByName( ctabitem.getText() );
        if ( dItem != null ) {
          dItem.dispose();
          input.setChanged();
        }
        break;
      case ADD_ITEM:
        TreeItem item = new TreeItem( wTreeScriptsItem, SWT.NULL );
        item.setImage( imageActiveScript );
        item.setText( ctabitem.getText() );
        input.setChanged();
        break;

      case RENAME_ITEM:
        input.setChanged();
        break;
      case SET_ACTIVE_ITEM:
        input.setChanged();
        break;
      default:
        break;
    }
  }
 
源代码17 项目: pentaho-kettle   文件: SelectObjectDialog.java
private void removeEmptyFolders( TreeItem[] treeitems ) {
  for ( TreeItem item : treeitems ) {
    if ( item.getImage().equals( GUIResource.getInstance().getImageArrow() ) && item.getItemCount() == 0 ) {
      item.dispose();
    } else {
      removeEmptyFolders( item.getItems() );
    }
  }
}
 
源代码18 项目: uima-uimaj   文件: TypeSection.java
/**
 * Handle remove type.
 *
 * @param item the item
 */
private void handleRemoveType(final TreeItem item) {

  TypeDescription td = getTypeDescriptionFromTableTreeItem(item);

  String sTypeNameToRemove = td.getName();

  // pop a dialog mentioning typesRequiringThisOne, saying that others must be
  // deleted first....
  if (null == showTypesRequiringThisOneMessage(sTypeNameToRemove, !ALLOWED))
    return;

  boolean bTypeInUseElsewhere = isTypeInUseElsewhere(sTypeNameToRemove);
  if (bTypeInUseElsewhere) {
    String sCascadeDeleteTitle = CASCADE_DELETE_WARNING;
    String sCascadeDeleteMessage = CASCADE_MESSAGE;
    boolean bContinue = MessageDialog.openConfirm(getSection().getShell(), sCascadeDeleteTitle,
            sCascadeDeleteMessage);
    if (!bContinue) {
      return;
    }
  }

  TypeDescription localTd = getLocalTypeDefinition(td);
  removeType(localTd, getTypeSystemDescription());

  if (isImportedType(td)) {
    // although the type itself still remains in the merged type system,
    // features may be removed by this action, so
    // a remerge is needed
    rebuildMergedTypeSystem();
    refresh();
  } else {
    removeType(td, getMergedTypeSystemDescription());
    // update GUI
    setSelectionOneUp(tt, item);
    item.dispose();
  }

  TypeFeature[] featuresToRemove = computeFeaturesToRemove(localTd,
          getMergedTypeSystemDescription().getType(td.getName()));

  if (bTypeInUseElsewhere && !isImportedType(td) && !isBuiltInType(td)) {
    deleteTypeOrFeatureMentions(sTypeNameToRemove, TYPES, null);
  }

  // if removing a type which is also imported or built-in, which is a supertype of something
  // this action can change the feature set.

  if (null != featuresToRemove)
    for (int i = 0; i < featuresToRemove.length; i++) {
      deleteTypeOrFeatureMentions(featuresToRemove[i].featureName, FEATURES,
              featuresToRemove[i].typeName);
    }

  editor.removeDirtyTypeName(sTypeNameToRemove);
  finishAction();
}
 
源代码19 项目: Rel   文件: RelPanel.java
private void removeSubtree(String section) {
	TreeItem root = treeRoots.get(section);
	if (root != null)
		treeRoots.remove(section);
	root.dispose();
}
 
源代码20 项目: uima-uimaj   文件: CapabilitySection.java
/**
 * Handle remove.
 *
 * @param removeItem the remove item
 * @param itemKind the item kind
 */
private void handleRemove(TreeItem removeItem, int itemKind) {
  int selectionIndex = tt.indexOf(tt.getSelection()[0]);
  Capability c = getCapability(removeItem);
  switch (itemKind) {
    case CS: {
      if (Window.CANCEL == Utility.popOkCancel("Confirm Remove",
              "This action will remove an entire capability set.  Please confirm.",
              MessageDialog.WARNING)) {
        maybeSetSelection(tt, selectionIndex + 1);
        return;
      }
      removeCapabilitySet(c);
      removeItem.dispose();
      break;
    }
    case LANG_ITEM: {
      c.setLanguagesSupported(stringArrayRemove(c.getLanguagesSupported(), removeItem
              .getText(NAME_COL)));
      removeItem.dispose();
      break;
    }
    case SOFA_ITEM: {
      if (Window.CANCEL == Utility
              .popOkCancel(
                      "Confirm Removal of Sofa",
                      "This action will remove this Sofa as a capability, and delete its mappings if no other capability set declares this Sofa."
                              + "  Please confirm.", MessageDialog.WARNING)) {
        maybeSetSelection(tt, selectionIndex + 1);
        return;
      }
      String sofaName = removeItem.getText(NAME_COL);
      boolean isInput = INPUT.equals(removeItem.getText(INPUT_COL));
      if (isInput)
        c.setInputSofas((String[]) Utility.removeElementFromArray(c.getInputSofas(), sofaName,
                String.class));
      else
        c.setOutputSofas((String[]) Utility.removeElementFromArray(c.getOutputSofas(), sofaName,
                String.class));
      removeItem.dispose();

      if (!anyCapabilitySetDeclaresSofa(sofaName, isInput)) {
        Comparator comparator = new Comparator() {
          @Override
          public int compare(Object o1, Object o2) {
            String name = (String) o1;
            SofaMapping sofaMapping = (SofaMapping) o2;
            if (name.equals(sofaMapping.getAggregateSofaName()))
              return 0;
            return 1;
          }
        };
        editor.getAeDescription().setSofaMappings(
                (SofaMapping[]) Utility.removeElementsFromArray(getSofaMappings(), sofaName,
                        SofaMapping.class, comparator));

        sofaMapSection.markStale();
      }
      break;
    }
    case TYPE: {
      if (Window.CANCEL == Utility.popOkCancel("Confirm Removal of Type",
              "This action will remove this type as a capability.  Please confirm.",
              MessageDialog.WARNING)) {
        maybeSetSelection(tt, selectionIndex + 1);
        return;
      }
      TreeItem[] features = removeItem.getItems();
      if (null != features)
        for (int i = 0; i < features.length; i++) {
          removeFeature(c, features[i]);
        }
      String typeNameToRemove = getFullyQualifiedName(removeItem);
      if (isInput(removeItem))
        c.setInputs(typeOrFeatureArrayRemove(c.getInputs(), typeNameToRemove));
      if (isOutput(removeItem) /* || isUpdate(removeItem) */)
        c.setOutputs(typeOrFeatureArrayRemove(c.getOutputs(), typeNameToRemove));

      removeItem.dispose();
      break;
    }
    case FEAT: {
      removeFeature(c, removeItem);
      break;
    }
    default:
      throw new InternalErrorCDE("invalid state");
  }

  maybeSetSelection(tt, selectionIndex - 1);
  finishAction();
}