use of org.netbeans.api.autoupdate.OperationException in project netbeans-rcp-lite by outersky.
the class PluginManager method install.
/**
* Open standard dialog for installing modules including declared dependencies.
* Shows it to the user, asks for confirmation, license acceptance, etc.
* The whole operation requires AWT dispatch thread access (to show the dialog)
* and blocks (until the user clicks through), so either call from AWT dispatch
* thread directly, or be sure you hold no locks and block no progress of other
* threads to avoid deadlocks.
*
* @param codenamebases the codenamebases of modules to install; must contain at least
* one codenamebase
* @param alternativeOptions alternative options possibly displayed in error
* dialog user may choose if it is not possible to install the plugin;
* if chosen the option is return value of this method
* @return <code>null</code> if all the requested modules have been successfully
* installed and/or activated, otherwise it returns the options user has
* selected in problem dialog, typically {@link NotifyDescriptor#DEFAULT_OPTION}
* (on esc), {@link NotifyDescriptor#CANCEL_OPTION} or
* any of <code>alternativeOptions</code>.
* @throws IllegalArgumentException if the <code>codenamebases</code> is empty
* @since 1.35
*/
@CheckForNull
public static Object install(@NonNull Set<String> codenamebases, @NonNull Object... alternativeOptions) {
Parameters.notNull("cnb", codenamebases);
Parameters.notNull("alternativeOptions", alternativeOptions);
if (codenamebases.isEmpty()) {
throw new IllegalArgumentException("No plugins to install");
}
try {
return new ModuleInstallerSupport(alternativeOptions).installPlugins(null, codenamebases);
} catch (OperationException ex) {
Logger.getLogger(PluginManager.class.getName()).log(Level.WARNING, null, ex);
}
return NotifyDescriptor.DEFAULT_OPTION;
}
use of org.netbeans.api.autoupdate.OperationException in project netbeans-rcp-lite by outersky.
the class CustomHandleStep method handleOperation.
private boolean handleOperation() {
final OperationSupport support = model.getCustomHandledContainer().getSupport();
assert support != null;
passed = false;
Runnable performOperation = new Runnable() {
public void run() {
try {
final ProgressHandle handle = ProgressHandleFactory.createHandle(isInstall ? getBundle("CustomHandleStep_Install_InstallingPlugins") : getBundle("CustomHandleStep_Uninstall_UninstallingPlugins"));
JComponent progressComponent = ProgressHandleFactory.createProgressComponent(handle);
JLabel mainLabel = ProgressHandleFactory.createMainLabelComponent(handle);
JLabel detailLabel = ProgressHandleFactory.createDetailLabelComponent(handle);
handle.setInitialDelay(0);
panel.waitAndSetProgressComponents(mainLabel, progressComponent, detailLabel);
restarter = support.doOperation(handle);
passed = true;
panel.waitAndSetProgressComponents(mainLabel, progressComponent, new JLabel(getBundle("CustomHandleStep_Done")));
} catch (OperationException ex) {
log.log(Level.INFO, ex.getMessage(), ex);
passed = false;
errorMessage = ex.getLocalizedMessage();
}
}
};
performOperation.run();
return passed;
}
use of org.netbeans.api.autoupdate.OperationException in project netbeans-rcp-lite by outersky.
the class UninstallStep method handleAction.
@NbBundle.Messages({ "UninstallStep_NullSupport_NullElements=Not found any elements for that operation.", "# {0} - invalid elements", "UninstallStep_NullSupport_InvalidElements=Found invalid element(s) {0} for that operation.", "UninstallStep_ProgressName_Uninstall=Uninstalling plugins", "UninstallStep_ProgressName_Activate=Activating plugins", "UninstallStep_ProgressName_Deactivate=Deactivating plugins", "UninstallStep_Done=Done.", "# {0} - A error message", "UninstallStep_Failed=Failed. {0}" })
private Restarter handleAction() throws OperationException {
assert model.getBaseContainer() != null : "getBaseContainers() returns not null container.";
support = (OperationSupport) model.getBaseContainer().getSupport();
assert support != null : "OperationSupport cannot be null because OperationContainer " + "contains elements: " + model.getBaseContainer().listAll() + " and invalid elements " + model.getBaseContainer().listInvalid();
if (support == null) {
err.log(Level.WARNING, "OperationSupport cannot be null because OperationContainer contains elements: " + "{0} and invalid elements {1}", new Object[] { model.getBaseContainer().listAll(), model.getBaseContainer().listInvalid() });
if (!model.getBaseContainer().listInvalid().isEmpty()) {
// cannot continue if there are invalid elements
throw new OperationException(OperationException.ERROR_TYPE.UNINSTALL, UninstallStep_NullSupport_InvalidElements(model.getBaseContainer().listInvalid()));
} else if (model.getBaseContainer().listAll().isEmpty()) {
// it's weird, there must be any elemets for uninstall
throw new OperationException(OperationException.ERROR_TYPE.UNINSTALL, UninstallStep_NullSupport_NullElements());
}
throw new OperationException(OperationException.ERROR_TYPE.UNINSTALL, "OperationSupport cannot be null because OperationContainer " + "contains elements: " + model.getBaseContainer().listAll() + " and invalid elements " + model.getBaseContainer().listInvalid());
}
ProgressHandle handle = null;
switch(model.getOperation()) {
case UNINSTALL:
handle = ProgressHandleFactory.createHandle(UninstallStep_ProgressName_Uninstall());
break;
case ENABLE:
handle = ProgressHandleFactory.createHandle(UninstallStep_ProgressName_Activate());
break;
case DISABLE:
handle = ProgressHandleFactory.createHandle(UninstallStep_ProgressName_Deactivate());
break;
default:
assert false : "Unknown OperationType " + model.getOperation();
}
JComponent progressComponent = ProgressHandleFactory.createProgressComponent(handle);
JLabel mainLabel = ProgressHandleFactory.createMainLabelComponent(handle);
JLabel detailLabel = ProgressHandleFactory.createDetailLabelComponent(handle);
model.modifyOptionsForDisabledCancel(wd);
panel.waitAndSetProgressComponents(mainLabel, progressComponent, detailLabel);
Restarter r = null;
try {
r = support.doOperation(handle);
panel.waitAndSetProgressComponents(mainLabel, progressComponent, new JLabel(UninstallStep_Done()));
} catch (OperationException ex) {
err.log(Level.INFO, ex.getMessage(), ex);
panel.waitAndSetProgressComponents(mainLabel, progressComponent, new JLabel(UninstallStep_Failed(ex.getLocalizedMessage())));
throw ex;
}
return r;
}
use of org.netbeans.api.autoupdate.OperationException in project netbeans-rcp-lite by outersky.
the class UninstallStep method doAction.
private void doAction() {
// proceed operation
Restarter r;
try {
if ((r = handleAction()) != null) {
presentActionNeedsRestart(r);
} else {
presentActionDone();
}
} catch (OperationException ex) {
presentActionFailed(ex);
}
fireChange();
}
use of org.netbeans.api.autoupdate.OperationException in project constellation by constellation-app.
the class DeveloperOptionsPanel method masterResetButtonActionPerformed.
// </editor-fold>//GEN-END:initComponents
private void masterResetButtonActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_masterResetButtonActionPerformed
Collection<UpdateElement> toUninstall = new ArrayList<>();
for (UpdateUnit unit : UpdateManager.getDefault().getUpdateUnits()) {
String codeName = unit.getCodeName();
if (!"au.gov.asd.tac.constellation.autoupdate".equals(codeName) && !codeName.startsWith("org.netbeans.") && !codeName.startsWith("org.openide.") && !codeName.startsWith("org.jdesktop.")) {
UpdateElement element = unit.getInstalled();
if (element != null) {
toUninstall.add(element);
}
}
}
OperationContainer<OperationSupport> operationContainer = OperationContainer.createForUninstall();
operationContainer.add(toUninstall);
OperationSupport operationSupport = operationContainer.getSupport();
try {
operationSupport.doOperation(null);
} catch (final OperationException ex) {
LOGGER.log(Level.SEVERE, ex.getLocalizedMessage(), ex);
}
}
Aggregations